From users-return-50826-archive-asf-public=cust-asf.ponee.io@activemq.apache.org Thu Dec 20 19:55:11 2018 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id 8E432180648 for ; Thu, 20 Dec 2018 19:55:10 +0100 (CET) Received: (qmail 82781 invoked by uid 500); 20 Dec 2018 18:55:09 -0000 Mailing-List: contact users-help@activemq.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@activemq.apache.org Delivered-To: mailing list users@activemq.apache.org Received: (qmail 82770 invoked by uid 99); 20 Dec 2018 18:55:09 -0000 Received: from mail-relay.apache.org (HELO mailrelay2-lw-us.apache.org) (207.244.88.137) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 20 Dec 2018 18:55:09 +0000 Received: from mail-oi1-f169.google.com (mail-oi1-f169.google.com [209.85.167.169]) by mailrelay2-lw-us.apache.org (ASF Mail Server at mailrelay2-lw-us.apache.org) with ESMTPSA id 813092D1B for ; Thu, 20 Dec 2018 18:55:08 +0000 (UTC) Received: by mail-oi1-f169.google.com with SMTP id v6so2766689oif.2 for ; Thu, 20 Dec 2018 10:55:08 -0800 (PST) X-Gm-Message-State: AA+aEWYqbM9N6lxFljw6R3mE0Rdf5++CE7VaLlX+yP3p8DDqCPlQSfzt vrR6lc5h6RM/pFf7DNSNy4dExOV1S+SgrRVZkSLB6Q== X-Google-Smtp-Source: AFSGD/WZrje6B6A4A+JzQ9AI8BRYhTHwHRI3MudQu5jPtWms9EeC5HEF6t1J8SDYlvQAGZz7lq0BV+nKbKWVoaGFr+w= X-Received: by 2002:aca:d414:: with SMTP id l20mr680oig.107.1545332107957; Thu, 20 Dec 2018 10:55:07 -0800 (PST) MIME-Version: 1.0 References: <1545247138226-0.post@n4.nabble.com> In-Reply-To: <1545247138226-0.post@n4.nabble.com> From: Justin Bertram Date: Thu, 20 Dec 2018 12:54:41 -0600 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: ActiveMQ-JBoss 5 integration problem To: users@activemq.apache.org Content-Type: multipart/alternative; boundary="0000000000005b0509057d78abeb" --0000000000005b0509057d78abeb Content-Type: text/plain; charset="UTF-8" Using the @ResourceAdapter("amq.jmsra.rar") annotation on the MDB and then configuring the ra.xml in the amq.jmsra.rar is not a terrible or unworkable solution. Each MDB can have it's own copy of the amq.jmsra.rar with a unique name and a unique ra.xml configuration as needed. Resource adapter archives can be exploded into directories (in the "deploy" directory) which makes it easy to modify the ra.xml. Looking at the activation specification options [1] for the ActiveMQ JCA RA I don't actually see a way to configure a server URL so it would appear that modifying the ra.xml is the only way to redirect the connection of the incoming adapter of the ActiveMQ JCA RA. You have the option of using the generic JMS JCA RA built into JBoss AS. I think all you need to do is remove the @ResourceAdapter("amq.jmsra.rar") from the MDB (so that it uses the default generic JCA RA) and adjust the activation configuration properties like so to use the JMSProviderLoader you've already configured: @MessageDriven(name = "TransactionMessageHandler", activationConfig = { @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"), @ActivationConfigProperty(propertyName = "destination", propertyValue = "activemq/queue/AMQTransauthRequest"), @ActivationConfigProperty(propertyName = "providerAdapterJNDI", propertyValue = "java:/AMQJMSProvider")}) Since the "AMQJMSProvider" you've configured is pointing to your remote server then the MDB should connect to and receive messages from that remote server. For what it's worth I haven't looked at this stuff in around 8 years so the details are a little fuzzy but it shouldn't be too hard to get it all working. Justin [1] http://activemq.apache.org/activation-spec-properties.html On Wed, Dec 19, 2018 at 3:18 PM srv123 wrote: > 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: > > > > activemq/QueueConnectionFactory > > > amq.jmsra.rar > > > javax.jms.QueueConnectionFactory > > type="java.lang.String">tcp://dedd1012:61616 > type="java.lang.String">admin > type="java.lang.String">admin > > 0 > 20 > 30000 > 5 > > > activemq/QueueConnectionFactoryNoTx > > > amq.jmsra.rar > > > javax.jms.QueueConnectionFactory > > type="java.lang.String">tcp://dedd1012:61616 > type="java.lang.String">admin > type="java.lang.String">admin > > 0 > 20 > 30000 > 5 > > > name="activemq.queue:name=AMQTransauthRequest"> > name="JNDIName">activemq/queue/AMQTransauthRequest > > optional-attribute-name="RARName">jboss.jca:service=RARDeployment,name='amq.jmsra.rar' > javax.jms.Queue > name="Properties">PhysicalName=transauth.exec.request > > name="activemq.queue:name=AMQTransauthResponse"> > name="JNDIName">activemq/queue/AMQTransauthResponse > > optional-attribute-name="RARName">jboss.jca:service=RARDeployment,name='amq.jmsra.rar' > javax.jms.Queue > name="Properties">PhysicalName=transauth.exec.response > > > > name="jboss.messaging:service=JMSProviderLoader,name=AMQJMSProvider"> > AMQJMSProvider > > name="ProviderAdapterClass">org.jboss.jms.jndi.JNDIProviderAdapter > name="FactoryRef">activemq/QueueConnectionFactory > name="QueueFactoryRef">activemq/QueueConnectionFactory > name="TopicFactoryRef">activemq/QueueConnectionFactory > xa=true > > > java.naming.factory.initial=org.apache.activemq.jndi.ActiveMQInitialContextFactory > java.naming.provider.url=tcp://dedd1012:61616 > > > > > > ra.xml inside of amq.jmsra.rar: > (here if I overwrite tcp://localhost:61616 with tcp://dedd1012:61616 then > it > works) > > > > > org.apache.activemq.ra.ActiveMQResourceAdapter > > > 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'. > > ServerUrl > java.lang.String > > tcp://localhost:61616 > > > > The default user name that will be used to > establish connections to the ActiveMQ server. > UserName > java.lang.String > defaultUser > > > The default password that will be used to log the > default user into the ActiveMQ server. > Password > java.lang.String > defaultPassword > > > The client id that will be set on the connection > that is established to the ActiveMQ server. > Clientid > java.lang.String > > > Boolean to configure if outbound connections > should > reuse the inbound connection's session for sending messages. > UseInboundSession > java.lang.Boolean > false > > > > > > 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. > > BrokerXmlConfig > java.lang.String > > > > > > > Any help would be greatly appreciated! > > Thanks, > srv > > > > > -- > Sent from: > http://activemq.2283324.n4.nabble.com/ActiveMQ-User-f2341805.html > --0000000000005b0509057d78abeb--