[jboss-jira] [JBoss JIRA] (WFLY-5213) Injecting external context to Artemis fails

Bartosz Andrzejewski (JIRA) issues at jboss.org
Tue Oct 18 06:36:00 EDT 2016


    [ https://issues.jboss.org/browse/WFLY-5213?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13308505#comment-13308505 ] 

Bartosz Andrzejewski commented on WFLY-5213:
--------------------------------------------

Hello [~okalman]

So I tried to do it your way, but still no success. Maybe I will post my configuration so you could see whats wrong with it.

Standalone artemis config:

{code:java}
<jms xmlns="urn:activemq:jms">
      <queue name="jms.queue.example.destination"/>
   </jms>
{code}

WildFly configuration:

{code:java}
//...
<outbound-socket-binding name="remote-artemis">
            <remote-destination host="192.168.56.10" port="61616"/>
        </outbound-socket-binding>
//...
<subsystem xmlns="urn:jboss:domain:messaging-activemq:1.0">
            <server name="default">
                <security-setting name="#">
                    <role name="guest" send="true" consume="true" create-non-durable-queue="true" delete-non-durable-queue="true"/>
                </security-setting>
                <address-setting name="#" dead-letter-address="jms.queue.DLQ" expiry-address="jms.queue.ExpiryQueue" max-size-bytes="10485760" page-size-bytes="2097152" message-counter-history-day-limit="10"/>
                <http-connector name="http-connector" socket-binding="http" endpoint="http-acceptor"/>
                <http-connector name="http-connector-throughput" socket-binding="http" endpoint="http-acceptor-throughput">
                    <param name="batch-delay" value="50"/>
                </http-connector>
                <remote-connector name="remote-artemis" socket-binding="remote-artemis"/>
                <in-vm-connector name="in-vm" server-id="0"/>
                <http-acceptor name="http-acceptor" http-listener="default"/>
                <http-acceptor name="http-acceptor-throughput" http-listener="default">
                    <param name="batch-delay" value="50"/>
                    <param name="direct-deliver" value="false"/>
                </http-acceptor>
                <in-vm-acceptor name="in-vm" server-id="0"/>
                <jms-queue name="ExpiryQueue" entries="java:/jms/queue/ExpiryQueue"/>
                <jms-queue name="DLQ" entries="java:/jms/queue/DLQ"/>
                <connection-factory name="RemoteConnectionFactory" entries="java:jboss/exported/jms/RemoteConnectionFactory" connectors="http-connector"/>
                <connection-factory name="InVmConnectionFactory" entries="java:/ConnectionFactory" connectors="in-vm"/>
                <pooled-connection-factory name="remote-artemis" entries="java:/jms/remoteCF" connectors="remote-artemis" user="user" password="password"/>
                <pooled-connection-factory name="activemq-ra" entries="java:/JmsXA java:jboss/DefaultJMSConnectionFactory" connectors="in-vm" transaction="xa"/>
            </server>
        </subsystem>
        <subsystem xmlns="urn:jboss:domain:naming:2.0">
            <bindings>
                <external-context name="java:global/remoteContext" module="org.apache.activemq.artemis" class="javax.naming.InitialContext">
                    <environment>
                        <property name="java.naming.factory.initial" value="org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory"/>
                        <property name="java.naming.provider.url" value="tcp://192.168.56.10:61616"/>
                        <property name="queue.jms.queue.example.destination" value="jms.queue.example.destination"/>
                    </environment>
                </external-context>
                <lookup name="java:/jms.queue.example.destination" lookup="java:global/remoteContext/jms.queue.example.destination"/>
            </bindings>
            <remote-naming/>
{code}

And I am trying to perform a test that way:

{code:java}
//Producer
public class MessageProductioner {

	@Inject
	@JMSConnectionFactory("java:/jms/remoteCF")
	@JMSPasswordCredential(userName = "user", password = "password")
	private JMSContext context;

	@Resource(lookup = "java:global/remoteContext/jms.queue.example.destination")
	private Queue queue;

	@Resource
	private TimerService timerService;

	@PostConstruct
	private void init() {
		timerService.createTimer(1000, null);
	}

	@Timeout
	public void hey() {
		context.createProducer().send(queue, "coming through");
	}

}
//Consumer
@MessageDriven(name = "MessageConsiumer", activationConfig = {
        @ActivationConfigProperty(propertyName = "connectionFactoryLookup", propertyValue = "java:/jms/remoteCF"),
        @ActivationConfigProperty(propertyName="user", propertyValue="user"),
        @ActivationConfigProperty(propertyName="password", propertyValue="password"),
        @ActivationConfigProperty(propertyName = "destinationLookup", propertyValue = "java:global/remoteContext/jms.queue.example.destination"),
        @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
        @ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge") })
public class MessageConsiumer implements MessageListener {

	@Override
	public void onMessage(Message message) {
		try {
			TextMessage msg = (TextMessage) message;
			System.out.println(msg.getText());
		} catch (JMSException e) {
			e.printStackTrace();
		}
		
	}
}
{code}


> Injecting external context to Artemis fails
> -------------------------------------------
>
>                 Key: WFLY-5213
>                 URL: https://issues.jboss.org/browse/WFLY-5213
>             Project: WildFly
>          Issue Type: Bug
>          Components: JMS
>    Affects Versions: 10.0.0.Beta2
>            Reporter: Ondřej Kalman
>            Assignee: Jeff Mesnil
>             Fix For: 10.0.0.CR1
>
>
> When external-context is defined in EAP and it's pointing to external Artemis broker, it can't be injected in to MDB via @Resource(lookup = "java:global/externalcontext"). Such injection results in null object.
> Injecting destinations from external context results in javax.ejb.EJBTransactionRolledbackException.



--
This message was sent by Atlassian JIRA
(v6.4.11#64026)



More information about the jboss-jira mailing list