[JBoss Messaging Development] - JBossEAP5IntegrationwithTibcoEMS
by mattik
mattik [https://community.jboss.org/people/mattik] modified the document:
"JBossEAP5IntegrationwithTibcoEMS"
To view the document, visit: https://community.jboss.org/docs/DOC-14734
--------------------------------------------------------------
This article highlights some of the basic steps required to integrate JBoss EAP 5 with TibcoEMS. This article should also work with JBoss EAP 4.x, however, I have not tested tested this at this time.
**
#Introduction Introduction
**
#Credits Credits
**
#TibcoEMS_Configuration TibcoEMS Configuration
***
#Step1 Step1
***
#Step2 Step2
**
#JBoss_Configuration JBoss Configuration
***
#Step1_875024 Step1
****
#Option1 Option1
****
#Option2 Option2
***
#Step2_788050 Step2
***
#Step3 Step3
***
#Step4 Step4
**
#When_Using_a_Client When Using a Client
***
#Step1_815855 Step1
***
#Step2_674926 Step2
**
#MDB_configuration MDB configuration
***
#MDB_Configuration_with_Automatic_Reconnection_ MDB Configuration with Automatic Reconnection
***
#How_to_make_the_sample_mdb_code_fully_recover_from_JMS_connection_issues How to make the sample mdb code fully recover from JMS connection issues?
***
#How_to_test_your_implementation_for_automatic_reconnectionrecovery_from_JMS_connection_issues How to test your implementation for automatic reconnection/recovery from JMS connection issues?
****
#Option1_167755 Option1
****
#Option2_812199 Option2
***
#How_to_use_a_durable_topic_subscriber_instead_for_the_mdb How to use a durable topic subscriber instead for the mdb?
h2. Introduction
This article differs from:
http://community.jboss.org/wiki/IntegrationWithTibcoEMS IntegrationWithTibcoEMS
and the TibcoEMS administration documents in the following:
* Does not replace and remove JBoss messaging from the JBoss Installation (JBoss messaging can still be removed, but this is optional since the DefaultJMSProvider has not been replaced)
* Defines a TIBCOJMSProvider
* Provides a DLQ configuration without changing standardjboss.xml and replacing the DefaultJMSProvider with TIBCOJMSProvider
* Has been tested on JBoss EAP 5
* Uses authentication with Tibco EMS
h2. Credits
The content in this page is based on TibcoEMS documentation for JBoss4.x. Some of the content has also been borrowed from the article:
http://community.jboss.org/wiki/IntegrationWithTibcoEMS IntegrationWithTibcoEMS
including the sample mdb code for testing.
A special thanks to Marjono Reksopuro, Susanta Mondal and Michael McKernan for their help with Tibco Administration, integration and testing for this configuration.
h2. TibcoEMS Configuration
The steps in this section outline the steps required to create a test queue on TibcoEMS as well as the DLQ.
** Please note this EMS configuration assumes the following:*
- Authorization enabled
- Username/Password are set to: admin/admin
- A single instance running locally: localhost with port of 7222.
- If you need to have FT Pairs for failover, the url should be changed from tcp://localhost:7222, tcp://localhost:7222 to tcp://firstmachine:firstport,tcp://secondmachine:secondport
h3. Step1
Start the tibemsd server and the tibemsadmin console.
Queues and Connection Factories
h3. Step2
Create two queues (queue/myTestQueue and queue/DLQ) and two XA connection factories (TIBXAQueueConnectionFactory and TIBXATopicConnectionFactory), by entering the following commands in tibemsadmin:
> connect
> create queue queue/myTestQueue
> create queue queue/DLQ
> create factory TIBXAQueueConnectionFactory xaqueue url=tcp://localhost:7222
> create factory TIBXATopicConnectionFactory xatopic url= tcp://localhost:7222
Tibco pairs for Failover:
> create factory TIBXAQueueConnectionFactory xaqueue url=tcp://localhost:7222, tcp://localhost:7222
> create factory TIBXATopicConnectionFactory xatopic url= tcp://localhost:7222, tcp://localhost:7222
h2. JBoss Configuration
The steps in this section outline the steps required to configure JBoss to connect withTibcoEMS.
h3. Step1
Add TIBCO EMS and the TIBCO EMS adapter class for JBoss to the CLASSPATH of the JBoss server. There are two options to accomplish this:
h4. Option1
Add the following lines under the <server> element in the file $JBOSS_HOME/jboss-as/server/myinstance/conf/jboss-service.xml:
<!-- TIBCO Enterprise Message Service classpath -->
<classpath codebase="file:/C:\tibco\ems\5.1\lib" archives="tibjms.jar" ></classpath>
h4. Option2
Copy tibjms.jar file to:
$JBOSS_HOME/jboss-as/server/myinstance/lib
h3. Step2
Create a new datasource file called tibco-jms-ds.xml or whatever name you prefer, and place it in:
$JBOSS_HOME/jboss-as/server/myinstance/deploy
And add the following contents to the file mentioned above:
<?xml version="1.0" encoding="UTF-8"?>
<connection-factories>
<!-- The Tibco JMS provider loader -->
<mbean code="org.jboss.jms.jndi.JMSProviderLoader" name=":service=JMSProviderLoader,name=TibjmsProvider">
<attribute name="ProviderName">TIBCOJMSProvider</attribute>
<attribute name="ProviderAdapterClass">org.jboss.jms.jndi.JNDIProviderAdapter</attribute>
<attribute name="QueueFactoryRef">TIBXAQueueConnectionFactory</attribute>
<attribute name="TopicFactoryRef">TIBXATopicConnectionFactory</attribute>
<attribute name="Properties">
java.naming.security.principal=admin
java.naming.security.credentials=admin
java.naming.factory.initial=com.tibco.tibjms.naming.TibjmsInitialContextFactory
java.naming.factory.url.pkgs=com.tibco.tibjms.naming
java.naming.provider.url=tcp://localhost:7222
</attribute>
</mbean>
<!-- JMS XA Resource adapter, use this to get transacted JMS in beans -->
<tx-connection-factory>
<jndi-name>TibcoXA</jndi-name>
<xa-transaction/>
<rar-name>jms-ra.rar</rar-name>
<connection-definition>org.jboss.resource.adapter.jms.JmsConnectionFactory</connection-definition>
<config-property name="SessionDefaultType" type="java.lang.String">javax.jms.Queue</config-property>
<config-property name="JmsProviderAdapterJNDI" type="java.lang.String">java:/TIBCOJMSProvider</config-property>
<max-pool-size>20</max-pool-size>
<security-domain-and-application>TibcoXARealm</security-domain-and-application>
</tx-connection-factory>
</connection-factories>
h3. Step3
Notice that a security domain reference is present in the tibco-jms-ds.xml file. Therefore, modify the file $JBOSS_HOME/jboss-as/server/myinstance/conf/login-config.xml file as follows and add the TibcoXARealm within the <properties> element:
<application-policy name="TibcoXARealm">
<authentication>
<login-module code="org.jboss.resource.security.ConfiguredIdentityLoginModule" flag="required">
<module-option name="principal">admin</module-option>
<module-option name="userName">admin</module-option>
<module-option name="password">admin</module-option>
<module-option name="managedConnectionFactoryName">jboss.jca:service=TxCM,name=TibcoXA</module-option>
</login-module>
</authentication>
</application-policy>
h3. Step4
When the JBoss server invokes JNDI and encounters the tibjmsnaming scheme, the server must be able to find the TIBCO Enterprise Message Service URLConnectionFactory. Therefore, modify the file $JBOSS_HOME/jboss-as/server/myinstance/conf/jndi.properties as follows:
Change:
java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
To
java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces:com.tibco.tibjms.naming
h2. When Using a Client
h3. Step1
When the client program invokes JNDI, it should use the TIBCO Enterprise Message Service JNDI server. Modify %JBOSS_CLIENT%\jndi.properties to use TIBCO Enterprise Message Service JNDI by setting the following property:
java.naming.factory.initial=com.tibco.tibjms.naming.TibjmsInitialContextFactory
h3. Step2
Add EMS_HOME\lib\tibjms.jar to the CLASSPATH of the client program.
h2. MDB configuration
The sample mdb code from can be used:
http://community.jboss.org/wiki/IntegrationWithTibcoEMS IntegrationWithTibcoEMS
Update your jboss.xml file to look as follows:
<?xml version="1.0"?>
<jboss>
<resource-managers>
<resource-manager>
<res-name>queuefactoryref</res-name>
<res-jndi-name>java:/TibcoXA</res-jndi-name>
</resource-manager>
</resource-managers>
<enterprise-beans>
<message-driven>
<ejb-name>SampleMDB</ejb-name>
<configuration-name>Tibco Message Driven Bean</configuration-name>
<destination-jndi-name>queue/myTestQueue</destination-jndi-name>
<mdb-user>admin</mdb-user>
<mdb-passwd>admin</mdb-passwd>
<resource-ref>
<res-ref-name>jms/QCF</res-ref-name>
<resource-name>queuefactoryref</resource-name>
</resource-ref>
</message-driven>
</enterprise-beans>
<!-- container configuration for Tibco EMS -->
<container-configurations>
<container-configuration extends="Standard Message Driven Bean">
<container-name>Tibco Message Driven Bean</container-name>
<invoker-proxy-binding-name>tibco-message-driven-bean</invoker-proxy-binding-name>
</container-configuration>
</container-configurations>
<!-- The JmsProviderAdapterJNDI must match the ProviderName in SERVER_HOME/deploy/tibco-jms-ds.xml file. -->
<invoker-proxy-bindings>
<invoker-proxy-binding>
<name>tibco-message-driven-bean</name>
<invoker-mbean>default</invoker-mbean>
<proxy-factory>org.jboss.ejb.plugins.jms.JMSContainerInvoker</proxy-factory>
<proxy-factory-config>
<JMSProviderAdapterJNDI>TIBCOJMSProvider</JMSProviderAdapterJNDI>
<ServerSessionPoolFactoryJNDI>StdJMSPool</ServerSessionPoolFactoryJNDI>
<MinimumSize>1</MinimumSize>
<MaximumSize>15</MaximumSize>
<KeepAliveMillis>30000</KeepAliveMillis>
<MaxMessages>1</MaxMessages>
<MDBConfig>
<ReconnectIntervalSec>10</ReconnectIntervalSec>
<DLQConfig>
<DestinationQueue>queue/DLQ</DestinationQueue>
<MaxTimesRedelivered>10</MaxTimesRedelivered>
<TimeToLive>0</TimeToLive>
<DLQUser>admin</DLQUser>
<DLQPassword>admin</DLQPassword>
</DLQConfig>
</MDBConfig>
</proxy-factory-config></proxy-factory>
</invoker-proxy-binding>
</invoker-proxy-bindings>
</jboss>
*Note: The above configuration uses an EJB2 configuration, for EJB3 the following annotations can be used:
@ActivationConfigProperty(propertyName="providerAdapterJNDI", propertyValue="java:/TIBCOJMSProvider"),
@ActivationConfigProperty(propertyName="DLQJNDIName", propertyValue="queue/DLQ"),
@ActivationConfigProperty(propertyName="DLQUser", propertyValue="admin"),
@ActivationConfigProperty(propertyName="DLQPassword",propertyValue="admin")
*Upon a restart of the JBoss instance, you shold have a working configuration.*
+----------------------- Below this line added by matti.kaikkonen(a)teliasonera.com (mailto:matti.kaikkonen@teliasonera.com) Sept 13, 2012 --------------------------------+
h3. MDB Configuration with Automatic Reconnection
If you have had a problem with your JMS clients not reconnecting after bouncing EMS or losing network connection then you want to look into this option. The problem here is that the number of times to attempt to reconnect to the JMS provider needs a new property "reconnectAttempts" and by default it is 5. This property is available from JBoss Application 5 GA. Prior to this version, reconnection attempts were infinite by default. In the above format it is not possible to define the reconnectAttempts. I have tested this with JBoss 5.1.0GA.
Update your jboss.xml file to look as follows - replace the invoker-proxy-binding block with following. Look here (https://community.jboss.org/docs/DOC-9352) for documentation.
<invoker-proxy-binding>
<name>tibco-message-driven-bean</name>
<invoker-mbean>default</invoker-mbean>
<proxy-factory>org.jboss.ejb.plugins.inflow.JBossJMSMessageEndpointFactory</proxy-factory>
<proxy-factory-config>
<activation-config>
<activation-config-property>
<activation-config-property-name>providerAdapterJNDI</activation-config-property-name>
<activation-config-property-value>TIBCOJMSProvider</activation-config-property-value>
</activation-config-property>
<activation-config-property>
<activation-config-property-name>minSession</activation-config-property-name>
<activation-config-property-value>1</activation-config-property-value>
</activation-config-property>
<activation-config-property>
<activation-config-property-name>maxSession</activation-config-property-name>
<activation-config-property-value>15</activation-config-property-value>
</activation-config-property>
<activation-config-property>
<activation-config-property-name>keepAlive</activation-config-property-name>
<activation-config-property-value>30000</activation-config-property-value>
</activation-config-property>
<activation-config-property>
<activation-config-property-name>maxMessages</activation-config-property-name>
<activation-config-property-value>1</activation-config-property-value>
</activation-config-property>
<activation-config-property>
<activation-config-property-name>reconnectInterval</activation-config-property-name>
<activation-config-property-value>10</activation-config-property-value>
</activation-config-property>
<activation-config-property>
<activation-config-property-name>reconnectAttempts</activation-config-property-name>
<activation-config-property-value>1000000</activation-config-property-value>
</activation-config-property>
<activation-config-property>
<activation-config-property-name>useDLQ</activation-config-property-name>
<activation-config-property-value>true</activation-config-property-value>
</activation-config-property>
<activation-config-property>
<activation-config-property-name>DLQHandler</activation-config-property-name>
<activation-config-property-value>org.jboss.resource.adapter.jms.inflow.dlq.GenericDLQHandler</activation-config-property-value>
</activation-config-property>
<activation-config-property>
<activation-config-property-name>DLQJNDIName</activation-config-property-name>
<activation-config-property-value>queue/DLQ</activation-config-property-value>
</activation-config-property>
<activation-config-property>
<activation-config-property-name>DLQUser</activation-config-property-name>
<activation-config-property-value>admin</activation-config-property-value>
</activation-config-property>
<activation-config-property>
<activation-config-property-name>DLQPassword</activation-config-property-name>
<activation-config-property-value>admin</activation-config-property-value>
</activation-config-property>
<activation-config-property>
<activation-config-property-name>DLQMaxResent</activation-config-property-name>
<activation-config-property-value>10</activation-config-property-value>
</activation-config-property>
</activation-config>
<endpoint-interceptors>
<interceptor>org.jboss.proxy.ClientMethodInterceptor</interceptor>
<interceptor>org.jboss.ejb.plugins.inflow.MessageEndpointInterceptor</interceptor>
<interceptor>org.jboss.proxy.TransactionInterceptor</interceptor>
<interceptor>org.jboss.invocation.InvokerInterceptor</interceptor>
</endpoint-interceptors>
</proxy-factory-config>
</invoker-proxy-binding>
h3. How to make the sample mdb code fully recover from JMS connection issues?
With the above change we have taken care of the message listener part so that the onMessage works after a disconnect. But the sendReply doesn't recover without some extra code. You need to catch the JMSException when sending the reply, and first close the session and connection (look at the ejbRemove), and then reconnect again (look at setup) before retrying to send the reply message.
h3. How to test your implementation for automatic reconnection/recovery from JMS connection issues?
h4. Option1
If you don't have access to a TIBCO EMS server that you can bounce or kill anytime then here is one possible way to test it. The idea is to manipulate the routing table of the linux or windows workstation where you run your JBoss and in that way simulate a loss of connectivity. Here are examples that I have used.
*Linux:* if the ip address of the TIBCO EMS server is 192.168.1.38 then
Simulate network issue
*route add -net 192.168.1.38 netmask 255.255.255.255 reject*
Recover connectivity*
*
*route del -net 192.168.1.38 netmask 255.255.255.255 reject*
This works also - in my case eth0 device is connected and eth1 is WLAN that is disconnected
*route add -net 192.168.1.38 netmask 255.255.255.0 dev eth1*
*Windows7**:* if the ip address of the TIBCO EMS server is 192.168.1.38 then
Simulate network issue
*route ADD 192.168.1.38 MASK 255.255.255.255 169.254.138.21 * # where 169.254.138.21 is my VMware Network Adapter Autoconfiguration address *
*
Recover connectivity*
*
*route DELETE 192.168.1.38*
h4. Option2
If you can bounce or kill TIBCO EMS then either do a clean shutdown (CTRL-C in the EMS console does that) or use kill -9 / Task Manager>End Process to simulate a crash.
h3. How to use a durable topic subscriber instead for the mdb?
To use the sample mdb code (change also reply to destination from queue to topic) you just need to change all references to queues to topics. That's not a problem. The configuration of jboss.xml and ejb-jar.xml is the trickier part. In the jboss.xml replace <resource-managers> and <enterprise-beans> blocks with following. This is tested with JBoss 5.1.0GA.
<resource-managers>
<resource-manager>
<res-name>topicfactoryref</res-name>
<res-jndi-name>java:/TibcoXA</res-jndi-name>
</resource-manager>
</resource-managers>
<enterprise-beans>
<message-driven>
<ejb-name>SampleMDB</ejb-name>
<configuration-name>Tibco Message Driven Bean</configuration-name>
<destination-jndi-name>topic/B</destination-jndi-name>
<mdb-user>admin</mdb-user>
<mdb-passwd>admin</mdb-passwd>
<mdb-subscription-id>SampleMDB</mdb-subscription-id>
<mdb-client-id>123</mdb-client-id>
<resource-ref>
<res-ref-name>jms/TCF</res-ref-name>
<resource-name>topicfactoryref</resource-name>
</resource-ref>
</message-driven>
</enterprise-beans>
And the following replaces the original ejb-jar.xml.
<?xml version="1.0"?>
<!DOCTYPE ejb-jar
PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN"
"http://java.sun.com/dtd/ejb-jar_2_0.dtd">
<ejb-jar>
<enterprise-beans>
<message-driven>
<ejb-name>SampleMDB</ejb-name>
<ejb-class>com.unisys.tibcojboss.mdb.SampleMDB</ejb-class>
<transaction-type>Container</transaction-type>
<acknowledge-mode>AUTO_ACKNOWLEDGE</acknowledge-mode>
<message-driven-destination>
<destination-type>javax.jms.Topic</destination-type>
<subscription-durability>Durable</subscription-durability>
</message-driven-destination>
<resource-ref>
<res-ref-name>jms/TCF</res-ref-name>
<res-type>javax.jms.TopicConnectionFactory</res-type>
<res-auth>Container</res-auth>
</resource-ref>
</message-driven>
</enterprise-beans>
</ejb-jar>
--------------------------------------------------------------
Comment by going to Community
[https://community.jboss.org/docs/DOC-14734]
Create a new document in JBoss Messaging Development at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=102&c...]
11 years, 7 months
[JBoss Messaging Development] - JBossEAP5IntegrationwithTibcoEMS
by mattik
mattik [https://community.jboss.org/people/mattik] modified the document:
"JBossEAP5IntegrationwithTibcoEMS"
To view the document, visit: https://community.jboss.org/docs/DOC-14734
--------------------------------------------------------------
This article highlights some of the basic steps required to integrate JBoss EAP 5 with TibcoEMS. This article should also work with JBoss EAP 4.x, however, I have not tested tested this at this time.
**
#Introduction Introduction
**
#Credits Credits
**
#TibcoEMS_Configuration TibcoEMS Configuration
***
#Step1 Step1
***
#Step2 Step2
**
#JBoss_Configuration JBoss Configuration
***
#Step1_775649 Step1
****
#Option1 Option1
****
#Option2 Option2
***
#Step2_429941 Step2
***
#Step3 Step3
***
#Step4 Step4
**
#When_Using_a_Client When Using a Client
***
#Step1_803113 Step1
***
#Step2_57961 Step2
**
#MDB_configuration MDB configuration
***
#_Below_this_line_added_by_mattikaikkonenteliasoneracom_Sept_13_2012_ ----------------------- Below this line added by matti.kaikkonen(a)teliasonera.com Sept 13, 2012 --------------------------------
***
#MDB_Configuration_with_Automatic_Reconnection_ MDB Configuration with Automatic Reconnection
***
#How_to_make_the_sample_mdb_code_fully_recover_from_JMS_connection_issues How to make the sample mdb code fully recover from JMS connection issues?
***
#How_to_use_a_durable_topic_subscriber_instead_for_the_mdb How to use a durable topic subscriber instead for the mdb?
h2. Introduction
This article differs from:
http://community.jboss.org/wiki/IntegrationWithTibcoEMS IntegrationWithTibcoEMS
and the TibcoEMS administration documents in the following:
* Does not replace and remove JBoss messaging from the JBoss Installation (JBoss messaging can still be removed, but this is optional since the DefaultJMSProvider has not been replaced)
* Defines a TIBCOJMSProvider
* Provides a DLQ configuration without changing standardjboss.xml and replacing the DefaultJMSProvider with TIBCOJMSProvider
* Has been tested on JBoss EAP 5
* Uses authentication with Tibco EMS
h2. Credits
The content in this page is based on TibcoEMS documentation for JBoss4.x. Some of the content has also been borrowed from the article:
http://community.jboss.org/wiki/IntegrationWithTibcoEMS IntegrationWithTibcoEMS
including the sample mdb code for testing.
A special thanks to Marjono Reksopuro, Susanta Mondal and Michael McKernan for their help with Tibco Administration, integration and testing for this configuration.
h2. TibcoEMS Configuration
The steps in this section outline the steps required to create a test queue on TibcoEMS as well as the DLQ.
** Please note this EMS configuration assumes the following:*
- Authorization enabled
- Username/Password are set to: admin/admin
- A single instance running locally: localhost with port of 7222.
- If you need to have FT Pairs for failover, the url should be changed from tcp://localhost:7222, tcp://localhost:7222 to tcp://firstmachine:firstport,tcp://secondmachine:secondport
h3. Step1
Start the tibemsd server and the tibemsadmin console.
Queues and Connection Factories
h3. Step2
Create two queues (queue/myTestQueue and queue/DLQ) and two XA connection factories (TIBXAQueueConnectionFactory and TIBXATopicConnectionFactory), by entering the following commands in tibemsadmin:
> connect
> create queue queue/myTestQueue
> create queue queue/DLQ
> create factory TIBXAQueueConnectionFactory xaqueue url=tcp://localhost:7222
> create factory TIBXATopicConnectionFactory xatopic url= tcp://localhost:7222
Tibco pairs for Failover:
> create factory TIBXAQueueConnectionFactory xaqueue url=tcp://localhost:7222, tcp://localhost:7222
> create factory TIBXATopicConnectionFactory xatopic url= tcp://localhost:7222, tcp://localhost:7222
h2. JBoss Configuration
The steps in this section outline the steps required to configure JBoss to connect withTibcoEMS.
h3. Step1
Add TIBCO EMS and the TIBCO EMS adapter class for JBoss to the CLASSPATH of the JBoss server. There are two options to accomplish this:
h4. Option1
Add the following lines under the <server> element in the file $JBOSS_HOME/jboss-as/server/myinstance/conf/jboss-service.xml:
<!-- TIBCO Enterprise Message Service classpath -->
<classpath codebase="file:/C:\tibco\ems\5.1\lib" archives="tibjms.jar" ></classpath>
h4. Option2
Copy tibjms.jar file to:
$JBOSS_HOME/jboss-as/server/myinstance/lib
h3. Step2
Create a new datasource file called tibco-jms-ds.xml or whatever name you prefer, and place it in:
$JBOSS_HOME/jboss-as/server/myinstance/deploy
And add the following contents to the file mentioned above:
<?xml version="1.0" encoding="UTF-8"?>
<connection-factories>
<!-- The Tibco JMS provider loader -->
<mbean code="org.jboss.jms.jndi.JMSProviderLoader" name=":service=JMSProviderLoader,name=TibjmsProvider">
<attribute name="ProviderName">TIBCOJMSProvider</attribute>
<attribute name="ProviderAdapterClass">org.jboss.jms.jndi.JNDIProviderAdapter</attribute>
<attribute name="QueueFactoryRef">TIBXAQueueConnectionFactory</attribute>
<attribute name="TopicFactoryRef">TIBXATopicConnectionFactory</attribute>
<attribute name="Properties">
java.naming.security.principal=admin
java.naming.security.credentials=admin
java.naming.factory.initial=com.tibco.tibjms.naming.TibjmsInitialContextFactory
java.naming.factory.url.pkgs=com.tibco.tibjms.naming
java.naming.provider.url=tcp://localhost:7222
</attribute>
</mbean>
<!-- JMS XA Resource adapter, use this to get transacted JMS in beans -->
<tx-connection-factory>
<jndi-name>TibcoXA</jndi-name>
<xa-transaction/>
<rar-name>jms-ra.rar</rar-name>
<connection-definition>org.jboss.resource.adapter.jms.JmsConnectionFactory</connection-definition>
<config-property name="SessionDefaultType" type="java.lang.String">javax.jms.Queue</config-property>
<config-property name="JmsProviderAdapterJNDI" type="java.lang.String">java:/TIBCOJMSProvider</config-property>
<max-pool-size>20</max-pool-size>
<security-domain-and-application>TibcoXARealm</security-domain-and-application>
</tx-connection-factory>
</connection-factories>
h3. Step3
Notice that a security domain reference is present in the tibco-jms-ds.xml file. Therefore, modify the file $JBOSS_HOME/jboss-as/server/myinstance/conf/login-config.xml file as follows and add the TibcoXARealm within the <properties> element:
<application-policy name="TibcoXARealm">
<authentication>
<login-module code="org.jboss.resource.security.ConfiguredIdentityLoginModule" flag="required">
<module-option name="principal">admin</module-option>
<module-option name="userName">admin</module-option>
<module-option name="password">admin</module-option>
<module-option name="managedConnectionFactoryName">jboss.jca:service=TxCM,name=TibcoXA</module-option>
</login-module>
</authentication>
</application-policy>
h3. Step4
When the JBoss server invokes JNDI and encounters the tibjmsnaming scheme, the server must be able to find the TIBCO Enterprise Message Service URLConnectionFactory. Therefore, modify the file $JBOSS_HOME/jboss-as/server/myinstance/conf/jndi.properties as follows:
Change:
java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
To
java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces:com.tibco.tibjms.naming
h2. When Using a Client
h3. Step1
When the client program invokes JNDI, it should use the TIBCO Enterprise Message Service JNDI server. Modify %JBOSS_CLIENT%\jndi.properties to use TIBCO Enterprise Message Service JNDI by setting the following property:
java.naming.factory.initial=com.tibco.tibjms.naming.TibjmsInitialContextFactory
h3. Step2
Add EMS_HOME\lib\tibjms.jar to the CLASSPATH of the client program.
h2. MDB configuration
The sample mdb code from can be used:
http://community.jboss.org/wiki/IntegrationWithTibcoEMS IntegrationWithTibcoEMS
Update your jboss.xml file to look as follows:
<?xml version="1.0"?>
<jboss>
<resource-managers>
<resource-manager>
<res-name>queuefactoryref</res-name>
<res-jndi-name>java:/TibcoXA</res-jndi-name>
</resource-manager>
</resource-managers>
<enterprise-beans>
<message-driven>
<ejb-name>SampleMDB</ejb-name>
<configuration-name>Tibco Message Driven Bean</configuration-name>
<destination-jndi-name>queue/myTestQueue</destination-jndi-name>
<mdb-user>admin</mdb-user>
<mdb-passwd>admin</mdb-passwd>
<resource-ref>
<res-ref-name>jms/QCF</res-ref-name>
<resource-name>queuefactoryref</resource-name>
</resource-ref>
</message-driven>
</enterprise-beans>
<!-- container configuration for Tibco EMS -->
<container-configurations>
<container-configuration extends="Standard Message Driven Bean">
<container-name>Tibco Message Driven Bean</container-name>
<invoker-proxy-binding-name>tibco-message-driven-bean</invoker-proxy-binding-name>
</container-configuration>
</container-configurations>
<!-- The JmsProviderAdapterJNDI must match the ProviderName in SERVER_HOME/deploy/tibco-jms-ds.xml file. -->
<invoker-proxy-bindings>
<invoker-proxy-binding>
<name>tibco-message-driven-bean</name>
<invoker-mbean>default</invoker-mbean>
<proxy-factory>org.jboss.ejb.plugins.jms.JMSContainerInvoker</proxy-factory>
<proxy-factory-config>
<JMSProviderAdapterJNDI>TIBCOJMSProvider</JMSProviderAdapterJNDI>
<ServerSessionPoolFactoryJNDI>StdJMSPool</ServerSessionPoolFactoryJNDI>
<MinimumSize>1</MinimumSize>
<MaximumSize>15</MaximumSize>
<KeepAliveMillis>30000</KeepAliveMillis>
<MaxMessages>1</MaxMessages>
<MDBConfig>
<ReconnectIntervalSec>10</ReconnectIntervalSec>
<DLQConfig>
<DestinationQueue>queue/DLQ</DestinationQueue>
<MaxTimesRedelivered>10</MaxTimesRedelivered>
<TimeToLive>0</TimeToLive>
<DLQUser>admin</DLQUser>
<DLQPassword>admin</DLQPassword>
</DLQConfig>
</MDBConfig>
</proxy-factory-config></proxy-factory>
</invoker-proxy-binding>
</invoker-proxy-bindings>
</jboss>
*Note: The above configuration uses an EJB2 configuration, for EJB3 the following annotations can be used:
@ActivationConfigProperty(propertyName="providerAdapterJNDI", propertyValue="java:/TIBCOJMSProvider"),
@ActivationConfigProperty(propertyName="DLQJNDIName", propertyValue="queue/DLQ"),
@ActivationConfigProperty(propertyName="DLQUser", propertyValue="admin"),
@ActivationConfigProperty(propertyName="DLQPassword",propertyValue="admin")
*Upon a restart of the JBoss instance, you shold have a working configuration.*
h3. +----------------------- Below this line added by matti.kaikkonen(a)teliasonera.com (mailto:matti.kaikkonen@teliasonera.com) Sept 13, 2012 --------------------------------+
h3. MDB Configuration with Automatic Reconnection
If you have had a problem with your JMS clients not reconnecting after bouncing EMS or losing network connection then you want to look into this option. The problem here is that the number of times to attempt to reconnect to the JMS provider needs a new property "reconnectAttempts" and by default it is 5. This property is available from JBoss Application 5 GA. Prior to this version, reconnection attempts were infinite by default. In the above format it is not possible to define the reconnectAttempts. I have tested this with JBoss 5.1.0GA.
Update your jboss.xml file to look as follows - replace the invoker-proxy-binding block with following. Look here (https://community.jboss.org/docs/DOC-9352) for documentation.
<invoker-proxy-binding>
<name>tibco-message-driven-bean</name>
<invoker-mbean>default</invoker-mbean>
<proxy-factory>org.jboss.ejb.plugins.inflow.JBossJMSMessageEndpointFactory</proxy-factory>
<proxy-factory-config>
<activation-config>
<activation-config-property>
<activation-config-property-name>providerAdapterJNDI</activation-config-property-name>
<activation-config-property-value>TIBCOJMSProvider</activation-config-property-value>
</activation-config-property>
<activation-config-property>
<activation-config-property-name>minSession</activation-config-property-name>
<activation-config-property-value>1</activation-config-property-value>
</activation-config-property>
<activation-config-property>
<activation-config-property-name>maxSession</activation-config-property-name>
<activation-config-property-value>15</activation-config-property-value>
</activation-config-property>
<activation-config-property>
<activation-config-property-name>keepAlive</activation-config-property-name>
<activation-config-property-value>30000</activation-config-property-value>
</activation-config-property>
<activation-config-property>
<activation-config-property-name>maxMessages</activation-config-property-name>
<activation-config-property-value>1</activation-config-property-value>
</activation-config-property>
<activation-config-property>
<activation-config-property-name>reconnectInterval</activation-config-property-name>
<activation-config-property-value>10</activation-config-property-value>
</activation-config-property>
<activation-config-property>
<activation-config-property-name>reconnectAttempts</activation-config-property-name>
<activation-config-property-value>1000000</activation-config-property-value>
</activation-config-property>
<activation-config-property>
<activation-config-property-name>useDLQ</activation-config-property-name>
<activation-config-property-value>true</activation-config-property-value>
</activation-config-property>
<activation-config-property>
<activation-config-property-name>DLQHandler</activation-config-property-name>
<activation-config-property-value>org.jboss.resource.adapter.jms.inflow.dlq.GenericDLQHandler</activation-config-property-value>
</activation-config-property>
<activation-config-property>
<activation-config-property-name>DLQJNDIName</activation-config-property-name>
<activation-config-property-value>queue/DLQ</activation-config-property-value>
</activation-config-property>
<activation-config-property>
<activation-config-property-name>DLQUser</activation-config-property-name>
<activation-config-property-value>admin</activation-config-property-value>
</activation-config-property>
<activation-config-property>
<activation-config-property-name>DLQPassword</activation-config-property-name>
<activation-config-property-value>admin</activation-config-property-value>
</activation-config-property>
<activation-config-property>
<activation-config-property-name>DLQMaxResent</activation-config-property-name>
<activation-config-property-value>10</activation-config-property-value>
</activation-config-property>
</activation-config>
<endpoint-interceptors>
<interceptor>org.jboss.proxy.ClientMethodInterceptor</interceptor>
<interceptor>org.jboss.ejb.plugins.inflow.MessageEndpointInterceptor</interceptor>
<interceptor>org.jboss.proxy.TransactionInterceptor</interceptor>
<interceptor>org.jboss.invocation.InvokerInterceptor</interceptor>
</endpoint-interceptors>
</proxy-factory-config>
</invoker-proxy-binding>
h3. How to make the sample mdb code fully recover from JMS connection issues?
With the above change we have taken care of the message listener part so that the onMessage works after a disconnect. But the sendReply doesn't recover without some extra code. You need to catch the JMSException when sending the reply, and first close the session and connection (look at the ejbRemove), and then reconnect again (look at setup) before retrying to send the reply message.
h3. How to use a durable topic subscriber instead for the mdb?
To use the sample mdb code (change also reply to destination from queue to topic) you just need to change all references to queues to topics. That's not a problem. The configuration of jboss.xml and ejb-jar.xml is the trickier part. In the jboss.xml replace <resource-managers> and <enterprise-beans> blocks with following. This is tested with JBoss 5.1.0GA.
<resource-managers>
<resource-manager>
<res-name>topicfactoryref</res-name>
<res-jndi-name>java:/TibcoXA</res-jndi-name>
</resource-manager>
</resource-managers>
<enterprise-beans>
<message-driven>
<ejb-name>SampleMDB</ejb-name>
<configuration-name>Tibco Message Driven Bean</configuration-name>
<destination-jndi-name>topic/B</destination-jndi-name>
<mdb-user>admin</mdb-user>
<mdb-passwd>admin</mdb-passwd>
<mdb-subscription-id>SampleMDB</mdb-subscription-id>
<mdb-client-id>123</mdb-client-id>
<resource-ref>
<res-ref-name>jms/TCF</res-ref-name>
<resource-name>topicfactoryref</resource-name>
</resource-ref>
</message-driven>
</enterprise-beans>
And the following replaces the original ejb-jar.xml.
<?xml version="1.0"?>
<!DOCTYPE ejb-jar
PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN"
"http://java.sun.com/dtd/ejb-jar_2_0.dtd">
<ejb-jar>
<enterprise-beans>
<message-driven>
<ejb-name>SampleMDB</ejb-name>
<ejb-class>com.unisys.tibcojboss.mdb.SampleMDB</ejb-class>
<transaction-type>Container</transaction-type>
<acknowledge-mode>AUTO_ACKNOWLEDGE</acknowledge-mode>
<message-driven-destination>
<destination-type>javax.jms.Topic</destination-type>
<subscription-durability>Durable</subscription-durability>
</message-driven-destination>
<resource-ref>
<res-ref-name>jms/TCF</res-ref-name>
<res-type>javax.jms.TopicConnectionFactory</res-type>
<res-auth>Container</res-auth>
</resource-ref>
</message-driven>
</enterprise-beans>
</ejb-jar>
--------------------------------------------------------------
Comment by going to Community
[https://community.jboss.org/docs/DOC-14734]
Create a new document in JBoss Messaging Development at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=102&c...]
11 years, 7 months
[JBoss AS 7 Development] - if-else control flow
by Tomaz Cerar
Tomaz Cerar [https://community.jboss.org/people/ctomc] modified the document:
"if-else control flow "
To view the document, visit: https://community.jboss.org/docs/DOC-18764
--------------------------------------------------------------
h4. if-else controll flow was introduced in 7.2 builds
With if-else control flow you can choose which set of commands and operations to execute based on a condition. The condition is a boolean expression which evaluates the response of the operation (or command) specified in the if statement. Let's look at an example
if (outcome != success) of /system-property=test:read-resource
/system-property=test:add(value=true)
end-if
The *if* statement can be read as "if the outcome attribute of /system-property=test:read-resource response is not success (which means the property does not exist) then add the property and initialize it to true".
To understand the condition expression better, the result of +/system-property=test:read-resource+ if the test property doesn't exist will be
[standalone@localhost:9999 /] /system-property=test:read-resource
{
"outcome" => "failed",
"failure-description" => "JBAS014807: Management resource '[(\"system-property\" => \"test\")]' not found",
"rolled-back" => true
}
You can see that the *outcome* attribute equals *failed*, so the expression in our *if* statement will evaluate to true and the body of the *if* will be executed. If we execute +read-resource+ after the *if* again we'll see
[standalone@localhost:9999 /] /system-property=test:read-resource
{
"outcome" => "success",
"result" => {"value" => "true"}
}
Here is another example which demonstrates *if* with *else* and inverts the true-false value every time it's executed. It also shows how you can navigate the response, i.e. it evaluates attribute *value* - the child *result* - using a dot.
if (result.value == true) of /system-property=test:read-resource
/system-property=test:write-attribute(name=value,value=false)
else
/system-property=test:write-attribute(name=value,value=true)
end-if
The *of* keyword can be followed by any management command or an operation which results in a response from the controller.
And condition expressions can contain
• boolean && (and), || (or) and parentheses to group and prioritize expressions;
• >, >=, < and <= in addition to == and !=;
• the whitespaces are insignificant and ignored.
E.g. something like this could be a valid condition expression: ((a==b || c.c1<=d && e.e1.e2>f) && g!=h || i>=j) && (k<l && m>n || o==p)
If you use a navigation path and the path doesn't exist then the expression (the comparison which involves the path) will evaluate to false.
The examples above are simple and show only one operation in the bodies of the *if* and *else* but there is no such limitation. Each if/else body is a batch (which will be translated into a single composite operation) and can contain any number of commands and operations. Although, nested if-else and try-catch-finally are not yet supported.
--------------------------------------------------------------
Comment by going to Community
[https://community.jboss.org/docs/DOC-18764]
Create a new document in JBoss AS 7 Development at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=102&c...]
11 years, 7 months