git.net

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

ActiveMQ-JBoss 5 integration problem


Hello *,

while working on an ActiveMQ-JBoss integration project, I have faced the
following issue:
I have a message driven bean (EJB3) and I want to receive messages from a
remote ActiveMQ server.

When I configure the remote ActiveMQ server (using a resource archive) for
the message driven bean, I don't get any messages. However, it works fine
when I create a connection factory manually in a test class, I can send and
receive messages without a problem. But with the message driven bean, it
just doesn't work. I get the following error in the server log:

19:11:13,721 ERROR [ActiveMQEndpointWorker] Endpoint will try to reconnect
to the JMS broker in 30 seconds
19:11:43,722 ERROR [ActiveMQEndpointWorker] Failed to connect to broker
[tcp://localhost:61616]: Could not connect to broker URL:
tcp://localhost:61616. Reason: java.net.ConnectException: Connection refused
(Connection refused)
javax.jms.JMSException: Could not connect to broker URL:
tcp://localhost:61616. Reason: java.net.ConnectException: Connection refused
(Connection refused)

I guess, it is because the settings for the ActiveMQ server are somehow
overwritten by the default values of RAR file (ra.xml). If I edit edit
manually (set the server url, username and password) the ra.xml inside of
the amq.jmsra.rar file and then repackage it, everything works fine, I get
the messages with the message driven bean. But this is not what I want to
do, it is obviously not a solution for an enterprise system where we have
multiple environments, and everything must be configured easily with
property files.

ActiveMQ version is 5.15.6, Jboss version is 5.1.2.
I suppose, the problem is JBoss, I know this is very old version, but this
is a big and old enterprise environment, that is what I have to use. With
JBoss 6 it is also working fine.

Any idea, how can I get this thing working? I already checked this
ActiveMQ-JBoss integration page, but didn't find anything that could be
useful: http://activemq.apache.org/jboss-integration.html

What is the best practise in this case? It should definitely work, because
it is working if I overwrite the default value, but that is definitely not
the way to go.

My message driven bean:


@MessageDriven(name = "TransactionMessageHandler", activationConfig = {
        @ActivationConfigProperty(propertyName = "destinationType",
propertyValue = "javax.jms.Queue"),
        @ActivationConfigProperty(propertyName = "useJndi", propertyValue =
"true"),
        @ActivationConfigProperty(propertyName = "destination",
propertyValue = "activemq/queue/AMQTransauthRequest"),
        @ActivationConfigProperty(propertyName = "acknowledgeMode",
propertyValue = "Auto-acknowledge")})
@ResourceAdapter("amq.jmsra.rar")
public class TransactionMessageHandler implements MessageListener {


	@Resource
	protected MessageDrivenContext context;

	@Override
	public void onMessage(Message message) {
		// CODE
	}

	private void processMessage(Message message) {
		// CODE
	}

}

amq-ds.xml:

<connection-factories>
    <tx-connection-factory>
       	<jndi-name>activemq/QueueConnectionFactory</jndi-name>
       	<xa-transaction/>
       	<track-connection-by-tx/>
       	<rar-name>amq.jmsra.rar</rar-name>
       
<connection-definition>javax.jms.QueueConnectionFactory</connection-definition>

	<config-property name="ServerUrl"
type="java.lang.String">tcp://dedd1012:61616</config-property>
	<config-property name="UserName"
type="java.lang.String">admin</config-property>
	<config-property name="Password"
type="java.lang.String">admin</config-property>

       	<min-pool-size>0</min-pool-size>
       	<max-pool-size>20</max-pool-size>
       	<blocking-timeout-millis>30000</blocking-timeout-millis>
       	<idle-timeout-minutes>5</idle-timeout-minutes>
    </tx-connection-factory>
    <no-tx-connection-factory>
	<jndi-name>activemq/QueueConnectionFactoryNoTx</jndi-name>
       	<xa-transaction/>
       	<track-connection-by-tx/>
       	<rar-name>amq.jmsra.rar</rar-name>
       
<connection-definition>javax.jms.QueueConnectionFactory</connection-definition>

	<config-property name="ServerUrl"
type="java.lang.String">tcp://dedd1012:61616</config-property>       	
	<config-property name="UserName"
type="java.lang.String">admin</config-property>
	<config-property name="Password"
type="java.lang.String">admin</config-property>

       	<min-pool-size>0</min-pool-size>
       	<max-pool-size>20</max-pool-size>
       	<blocking-timeout-millis>30000</blocking-timeout-millis>
       	<idle-timeout-minutes>5</idle-timeout-minutes>
    </no-tx-connection-factory>        

	<mbean code="org.jboss.resource.deployment.AdminObject"
name="activemq.queue:name=AMQTransauthRequest">
      <attribute
name="JNDIName">activemq/queue/AMQTransauthRequest</attribute>
      <depends
optional-attribute-name="RARName">jboss.jca:service=RARDeployment,name='amq.jmsra.rar'</depends>
      <attribute name="Type">javax.jms.Queue</attribute>
      <attribute
name="Properties">PhysicalName=transauth.exec.request</attribute>
   </mbean>
   <mbean code="org.jboss.resource.deployment.AdminObject"
name="activemq.queue:name=AMQTransauthResponse">
      <attribute
name="JNDIName">activemq/queue/AMQTransauthResponse</attribute>
      <depends
optional-attribute-name="RARName">jboss.jca:service=RARDeployment,name='amq.jmsra.rar'</depends>
      <attribute name="Type">javax.jms.Queue</attribute>
      <attribute
name="Properties">PhysicalName=transauth.exec.response</attribute>
   </mbean>


    <mbean code="org.jboss.jms.jndi.JMSProviderLoader"
name="jboss.messaging:service=JMSProviderLoader,name=AMQJMSProvider">
        <attribute name="ProviderName">AMQJMSProvider</attribute>
        <attribute
name="ProviderAdapterClass">org.jboss.jms.jndi.JNDIProviderAdapter</attribute>
        <attribute
name="FactoryRef">activemq/QueueConnectionFactory</attribute>
        <attribute
name="QueueFactoryRef">activemq/QueueConnectionFactory</attribute>
        <attribute
name="TopicFactoryRef">activemq/QueueConnectionFactory</attribute>
        <attribute name="Properties">xa=true
   
java.naming.factory.initial=org.apache.activemq.jndi.ActiveMQInitialContextFactory
    java.naming.provider.url=tcp://dedd1012:61616
	</attribute>
    </mbean>
	
</connection-factories>

ra.xml inside of amq.jmsra.rar:
(here if I overwrite tcp://localhost:61616 with tcp://dedd1012:61616 then it
works)

<resourceadapter>
       
<resourceadapter-class>org.apache.activemq.ra.ActiveMQResourceAdapter</resourceadapter-class>
        <config-property>
            <description>
              The URL to the ActiveMQ server that you want this connection
to connect to.  If using
              an embedded broker, this value should be 'vm://localhost'.
            </description>
            <config-property-name>ServerUrl</config-property-name>
            <config-property-type>java.lang.String</config-property-type>
           
<config-property-value>tcp://localhost:61616</config-property-value>
            
        </config-property>
        <config-property>
            <description>The default user name that will be used to
establish connections to the ActiveMQ server.</description>
            <config-property-name>UserName</config-property-name>
            <config-property-type>java.lang.String</config-property-type>
            <config-property-value>defaultUser</config-property-value>
        </config-property>
        <config-property>
            <description>The default password that will be used to log the
default user into the ActiveMQ server.</description>
            <config-property-name>Password</config-property-name>
            <config-property-type>java.lang.String</config-property-type>
            <config-property-value>defaultPassword</config-property-value>
        </config-property>
        <config-property>
            <description>The client id that will be set on the connection
that is established to the ActiveMQ server.</description>
            <config-property-name>Clientid</config-property-name>
            <config-property-type>java.lang.String</config-property-type>
        </config-property>
        <config-property>
            <description>Boolean to configure if outbound connections should
reuse the inbound connection's session for sending messages.</description>
            <config-property-name>UseInboundSession</config-property-name>
            <config-property-type>java.lang.Boolean</config-property-type>
            <config-property-value>false</config-property-value>
        </config-property>

			  
        <config-property>
            <description>
              Sets the XML configuration file used to configure the embedded
ActiveMQ broker via 
              Spring if using embedded mode.
              
              BrokerXmlConfig is the filename which is assumed to be on the
classpath unless 
              a URL is specified. So a value of foo/bar.xml would be assumed
to be on the 
              classpath whereas file:dir/file.xml would use the file system. 
              Any valid URL string is supported.              
            </description>
            <config-property-name>BrokerXmlConfig</config-property-name>
            <config-property-type>java.lang.String</config-property-type>
            <config-property-value></config-property-value>
            
        </config-property>

</resourceadapter>

Any help would be greatly appreciated!

Thanks,
srv




--
Sent from: http://activemq.2283324.n4.nabble.com/ActiveMQ-User-f2341805.html