piątek, listopada 22, 2013

Configure Tibco EMS provider for JBoss EAP 5.x

Put jms.jar and tibjms.jar to lib/endorsed.

Add into server/default/deploy/messaging/jms-ds.xml:
<mbean code="org.jboss.jms.jndi.JMSProviderLoader"
          name="jboss.messaging:service=JMSProviderLoader,name=EMSProvider">
      <attribute name="ProviderName">DefaultEMSProvider</attribute>
      <attribute name="ProviderAdapterClass">org.jboss.jms.jndi.JNDIProviderAdapter</attribute>
      <attribute name="FactoryRef">ConnectionFactory</attribute>
      <attribute name="QueueFactoryRef">QueueConnectionFactory</attribute>
      <attribute name="TopicFactoryRef">TopicConnectionFactory</attribute>
   <attribute name="Properties">
  java.naming.security.principal=admin
  java.naming.security.credentials=Adm1n
  java.naming.factory.initial=com.tibco.tibjms.naming.TibjmsInitialContextFactory
  java.naming.factory.url.pkgs=com.tibco.tibjms.naming
  java.naming.provider.url=tibjmsnaming://tb-dev2.dc2:7222
   </attribute>
   </mbean>
In tibemsadmin execute:
create queue queue/DLQ
create queue testQueue
commit

Write MDB:

import javax.ejb.ActivationConfigProperty;
import javax.ejb.MessageDriven;
import javax.jms.Message;
import javax.jms.MessageListener;

@MessageDriven(
activationConfig = {
 @ActivationConfigProperty(propertyName = "destination", propertyValue = "testQueue"),
 @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
 @ActivationConfigProperty(propertyName = "providerAdapterJNDI", propertyValue = "java:/DefaultEMSProvider"),
 @ActivationConfigProperty(propertyName = "user", propertyValue = "user"),
 @ActivationConfigProperty(propertyName = "password", propertyValue = "pass"),
 @ActivationConfigProperty(propertyName = "DLQUser", propertyValue = "user"),
 @ActivationConfigProperty(propertyName = "DLQPassword", propertyValue = "pass")
},
mappedName = "testQueue")
public class TestQueue implements MessageListener {
    public TestQueue() {}
    public void onMessage(Message message) {
        System.out.println(message+"");    
    }
}

/** see org.jboss.resource.adapter.jms.inflow.JmsActivationSpec for all properties **/

And you've got it:

10:39:37,064 INFO [STDOUT] TextMessage={ Header={ JMSMessageID={ID:EMS-TEST.D965 28614F411790C:7} JMSDestination={Queue[testQueue]} JMSReplyTo={null} JMSDelivery Mode={PERSISTENT} JMSRedelivered={false} JMSCorrelationID={null} JMSType={null} JMSTimestamp={Fri Nov 22 10:39:36 CET 2013} JMSExpiration={0} JMSPriority={4} } Properties={ } Text={2013-11-22T10:39:37.028+01:00} }

0 komentarze: