...
Code Block | ||
---|---|---|
| ||
<bean id="endpointRegistry" class="com.epam.fej.routing.endpoint.EndpointRegistryAdapter" c:destinationsRegister-ref="destinationsRegister"/> |
JMS Transport Adapter
There are several ways to add JMS connectivity into FEJ container. fej-jms.xml
configuration file already contains basic configuration for JMS adapter:
Code Block | ||
---|---|---|
| ||
<bean id="jmsProperties" class="org.springframework.beans.factory.config.PropertiesFactoryBean"
p:location="classpath:jms-adaptor.properties"/>
<bean id="jmsConfig" class="com.epam.fixengine.jms.config.Config"
c:prefix="jms.adaptor"
c:properties-ref="jmsProperties">
</bean>
<bean id="jmsConfigRegister" class="com.epam.fej.jms.DefaultJmsConfigsRegister"
p:jmsManager-ref="jmsAdaptorManager"
c:config-ref="jmsConfig" init-method="init"/>
<bean id="jmsClientFactory" class="com.epam.fixengine.jms.client.JMSClientFactory" factory-method="getInstance"/>
<bean id="jmsAdaptorManager" class="com.epam.fej.jms.JmsAdapterManager"
c:endpointRegistry-ref="endpointRegistry"
c:clientFactory-ref="jmsClientFactory"
depends-on="rulesConfigManager"/> |
jms-adaptor.properties file contains parameters for JMS producers and consumers (FIXAJ JMS Adaptor properties). jmsConfigRegister
bean (com.epam.fej.jms.DefaultJmsConfigsRegister) is responsible for loading JMS session contexts (SessionContext) from configuration file and registering them with jmsAdaptorManager (com.epam.fej.jms.JmsAdaptorManager) for routing engine. JmsAdaptorManager builds source and destination endpoints adapters from given SessionContext objects and register them in server.
Info |
---|
If you want use your own Configuration Factory you can use JmsManager implementation for building and registering SessionContext instances also. |
DefaultJmsConfigsRegister produces SessionContext
via JmsContextFactory
implementation. By default it uses com.epam.fej.jms.JndiJmsSessionContextFactory implementation but you can set you own implementation via DefaultJmsConfigsRegister.setJmsContextFactory(JmsContextFactory jmsContextFactory)
. Also you can use com.epam.fej.jms.SimpleJmsContextFactory with your definition javax.jms.ConnectionFactory
Code Block | ||
---|---|---|
| ||
public SessionContext createSessionContext(JmsConfig config) {
final ConnectionInfo connectionInfo = config.getConnectionInfo();
final SessionInfo sessionInfo = config.getSessionInfo();
return new SessionContext(connectionInfo, sessionInfo, null, jmsContextFactory.createContext(config));
} |
Info | |||||
---|---|---|---|---|---|
Please note that
|
Custom connection factory instead of JNDI
Custom jms connection factory could be used in few ways:
Declaring
ConnectionFactory
in Spring and inject it inSimpleJmsContextFactory
:Code Block language xml <bean id="jmsConfigRegister" class="com.epam.fej.jms.DefaultJmsConfigsRegister" p:jmsManager-ref="jmsAdaptorManager" p:jmsContextFactory-ref="jmsContextFactory" c:config-ref="jmsConfig" init-method="init"/> <bean id="jmsConnectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory" c:brokerURL-ref="${jms.broker.url}"/> <bean id="jmsContextFactory" class="com.epam.fej.jms.SimpleJmsContextFactory" c:connectionFactory-ref="jmsConnectionFactory"/>
Implement your own
JmsContextFactory
and pass it as a parameter forDefaultJmsConfigRegister
:Code Block language java public class ActiveMqJmsContextFactory implements JmsContextFactory { @Override public JMSContext createContext(JmsConfig config) { return new SimpleJmsContext(new ActiveMQConnectionFactory( config.getConnectionInfo().getProviderURL()), config.getConnectionInfo()); } }
Code Block language xml <bean id="activeMqContextFactory" class="com.epam.fej.jms.ActiveMqJmsContextFactory"/> <bean id="jmsConfigRegister" class="com.epam.fej.jms.DefaultJmsConfigsRegister" p:jmsManager-ref="jmsAdaptorManager" p:jmsContextFactory-ref="activeMqContextFactory" c:config-ref="jmsConfig" init-method="init"/>