Connect to horneQ from another system - hornetq

I run a hornetQ in standalone mode with its default configuration and I can connect to it from local system, If I want to connect from another system which configurations must be changed to make this possible?!

You first need to define what you mean by another system, did you mean another HornetQ instance, or did you mean another JMS Server?
What's the connection medium? you want a Bridge between hornetQ and other JMS Systems? look at the JMS Bridge on the hornetQ documentation
You want a client to connect to different Message servers? look at the Stomp protocol and several clients available from apache / activeMQ guys. HOrnetQ supports Stomp natively on the server's side.

You need to configure transports, Netty transports.
Take a look at http://docs.jboss.org/hornetq/2.2.14.Final/user-manual/en/html_single/index.html#configuring-transports

These are my configurations
hornetq-configuration.xml:
<configuration xmlns="urn:hornetq" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:hornetq /schema/hornetq-configuration.xsd">
<connectors>
<connector name="netty-connector">
<factory-class>org.hornetq.core.remoting.impl.netty.NettyConnectorFactory</factory-class>
<param key="port" value="5446"/>
</connector>
</connectors>
<acceptors>
<acceptor name="netty-acceptor">
<factory-class>org.hornetq.core.remoting.impl.netty.NettyAcceptorFactory</factory-class>
<param key="port" value="5446"/>
<param key="host" value="0.0.0.0"/>
</acceptor>
</acceptors>
</configuration>
hornetq-beans.xml:
<bean name="Naming" class="org.jnp.server.NamingBeanImpl"/>
<bean name="JNDIServer" class="org.jnp.server.Main">
<property name="namingInfo">
<inject bean="Naming"/>
</property>
<property name="port">1099</property>
<property name="bindAddress">0.0.0.0</property>
<property name="rmiPort">1098</property>
<property name="rmiBindAddress">0.0.0.0</property>
</bean>

Related

Spring Integration - Apache ActiveMQ to Kafka

I am using the below configuration for integrating activemq with kafka. I receive message from activemq and forwards it to kafka. However, i am noticing that messages are getting dequeued from JMS Queue but messages are not going to kafka.
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jms="http://www.springframework.org/schema/integration/jms"
xmlns:integration="http://www.springframework.org/schema/integration"
xmlns:int-kafka="http://www.springframework.org/schema/integration/kafka"
xmlns:task="http://www.springframework.org/schema/task"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/integration/jms
http://www.springframework.org/schema/integration/jms/spring-integration-jms.xsd
http://www.springframework.org/schema/integration/kafka
http://www.springframework.org/schema/integration/kafka/spring-integration-kafka.xsd">
<jms:message-driven-channel-adapter
id="helloJMSAdapater" destination="helloJMSQueue" connection-factory="jmsConnectionfactory"
channel="helloChannel" extract-payload="true" />
<integration:channel id="helloChannel" />
<integration:service-activator id="sayHelloServiceActivator"
input-channel="helloChannel" ref="sayHelloService" method="sayHello" />
<int-kafka:outbound-channel-adapter
id="kafkaOutboundChannelAdapter" kafka-template="template"
auto-startup="false" sync="true" channel="helloChannel" topic="test1234"
>
</int-kafka:outbound-channel-adapter>
<bean id="template" class="org.springframework.kafka.core.KafkaTemplate">
<constructor-arg>
<bean class="org.springframework.kafka.core.DefaultKafkaProducerFactory">
<constructor-arg>
<map>
<entry key="bootstrap.servers" value="localhost:9092" />
<!--entry key="retries" value="5" /> <entry key="batch.size" value="16384"
/> <entry key="linger.ms" value="1" /> <entry key="buffer.memory" value="33554432"
/> < entry key="key.serializer" value="org.apache.kafka.common.serialization.StringSerializer"
/> <entry key="value.serializer" value="org.apache.kafka.common.serialization.StringSerializer"
/ -->
</map>
</constructor-arg>
</bean>
</constructor-arg>
</bean>
</beans>
Also, in case there is any issue from Kafka, it is not even reporting any exception stack trace.
Did i miss anything ?
Your messages are consumed by sayHelloServiceActivator.
So change your helloChannel channel type to
<publish-subscribe-channel id="helloChannel"/>
Default is DirectChannel
The DirectChannel has point-to-point semantics but otherwise is more
similar to the PublishSubscribeChannel than any of the queue-based
channel implementations described above. It implements the
SubscribableChannel interface instead of the PollableChannel
interface, so it dispatches Messages directly to a subscriber. As a
point-to-point channel, however, it differs from the
PublishSubscribeChannel in that it will only send each Message to a
single subscribed MessageHandler.
As #Hassen Bennour says, if you want to send a message to two consumers, you need a publish/subscribe channel.
That said, you have auto-startup="false" on the kafka adapter, so it won't even be subscribed to the channel.
If it was started, with your current configuration messages would be sent round-robin alternately to the service activator and adapter.

Configure JMS Divert JBoss7 (HornetQ)

I would like to configure a divert for my hornetq topics/queues. I am using JBoss 7
I configure my HornetQ in messaging subsystem in standalone.xml
<subsystem xmlns="urn:jboss:domain:messaging:1.3">
<hornetq-server>
I configure queues and topics here too
<jms-queue name="topic1">
<entry name="queue/queue1"/>
<entry name="java:jboss/exported/jms/queue/queue1"/>
</jms-queue>
<jms-topic name="topic1">
<entry name="topic/topic1"/>
<entry name="java:jboss/exported/jms/topic/topic1"/>
</jms-topic>
I would like to configure a divert..to divert the topic onto the queue like so:
<!-- Attempting divert-->
<divert name="my-divert">
<address>jms.topic.topic1</address>
<forwarding-address>jms.queue.topic1</forwarding-address>
<exclusive>true</exclusive> </divert> -->
<!-- end divert-->
</hornetq-server>
If I place it in the stanalone.xml in messaging subsystem Jboss will not parse this on startup. Where should I place this config - can it live in stanadalone.xml?
Thanks
I was placing the divert in wrong part of subsystem, this can be easily achieved by running the following command using jboss-cli
/subsystem=messaging/hornetq-server=default/divert=my-divert:add(divert-address=jms.topic.topic1,forwarding-address=jms.queue.queue1,exclusive=true)

Set keep-alive in HttpClient in Spring xml

We are using the apache HttpClient library to manage a pool of connections for some Java remoting.
Looking at the TCP traffic, it appears that the keep-alive flag is NOT being set, and our firewall is chopping off these connections.
Our spring config looks like this:
<bean name="httpClient" class="org.apache.commons.httpclient.HttpClient">
<property name="timeout" value="${pdcCreditCheck.maxTimeout}"/>
<property name="httpConnectionManager" ref="remotingConnectionManger"/>
</bean>
<bean id="remotingConnectionManger"
class="org.apache.commons.httpclient.MultiThreadedHttpConnectionManager">
<property name="maxTotalConnections" value="5"/>
<property name="maxConnectionsPerHost" value="5"/>
</bean>
I was hoping that there might be some flag I could set here, which corresponds to the TCP keep-alive flag.
Any help would be appreciated.
You might try to use the JVM flag http.keepAlive. For more info:
http://docs.oracle.com/javase/7/docs/technotes/guides/net/properties.html

Cannot start HornetQ without JMS and JNDI

If I run HornetQ with config\stand-alone\non-clustered config files, the HornetQ server starts up fine.
If I remove the JNDI and JMS sections from the hornetq-beans.xml file:
<!-- JNDI server. Disable this if you don't want JNDI -->
<bean name="JNDIServer" class="org.jnp.server.Main">
<property name="namingInfo">
<inject bean="Naming"/>
</property>
<property name="port">1099</property>
<property name="bindAddress">localhost</property>
<property name="rmiPort">1098</property>
<property name="rmiBindAddress">localhost</property>
</bean>
AND
<!-- The JMS server -->
<bean name="JMSServerManager" class="org.hornetq.jms.server.impl.JMSServerManagerImpl">
<constructor>
<parameter>
<inject bean="HornetQServer"/>
</parameter>
</constructor>
</bean>
I get the server dying immediately. This is the output I get:
C:\development\hornetQ\hornetq-2.2.14.Final\bin>run.bat ..\config\custom
A subdirectory or file ..\logs already exists.
***********************************************************************************
"java -XX:+UseParallelGC -XX:+AggressiveOpts -XX:+UseFastAccessorMethods -Xms512M - Xmx1024M -Dhornetq.config.dir=..\config\custom
-Djava.util.logging.config.file=..\config\custom\logging.properties -java.library.path=. -classpath ..\config\custom;..\schemas\;
C:\development\hornetQ\hornetq-2.2.14.Final\lib\hornetq-bootstrap.jar;C:\development\hornetQ\hornetq-2.2.14.Final\lib\hornetq-core-client-java5.jar;
C:\development\hornetQ\hornetq-2.2.14.Final\lib\hornetq-core-client.jar;C:\development\hornetQ\hornetq-2.2.14.Final\lib\hornetq-core.jar;
...etc.
***********************************************************************************
* [main] 28-Aug 11:7:22,132 INFO [HornetQBootstrapServer] Starting HornetQ Server
* [main] 28-Aug 11:7:23,91 WARNING [FileConfigurationParser] AIO wasn't located on this platform, it will fall back to using pure Java NIO. If your platform is Linux, install
LibAIO to enable the AIO journal
* [hornetq-shutdown-thread] 28-Aug 11:7:23,147 INFO [HornetQBootstrapServer] Stopping HornetQ Server...
Would appreciate if someone would tell me what I'm doing wrong.

JbossESB jmsProvider cannot convert IBMMQ JMS Message JMSTextMessage

I am trying to integrate IBMMQ v6.0.2 with jbossESB.
we have local Queue available on IBMMQ on one of our QA QUEUEMANAGER.
I am able to listen to the QUEUE using JMSprovider of jboss ESB. As soon as a message (of type jms_text ) is dropped , esb listen to it and pick it up and before it hit the next action it throws following error message.
ERROR [JmsComposer] Unsupported JMS message type: com.ibm.jms.JMSTextMessage
Here are the steps I followed.
jboss-service.mxl : Defined Connection Factory and QUEUE
added jars ( com.ibm.mq.* ) to ${jbossesb}/server/${mynode}/lib
Added jms lsinterner configuration on jboss-esb.xml
Please guide me what I m missing here... Do I need to create custom MessagePlugin ?
jboss-esb looks like this
<jms-provider name="WSMQ" connection-factory="MQQueueConnectionFactory">
<jms-bus busid="queuestartGwChannel"> <jms-message-filter
dest-type="QUEUE"
dest-name="wsmq/SerivceOrderQueue"
acknowledge-mode ="AUTO_ACKNOWLEDGE"
/>
</jms-bus>
<jms-bus busid="queuestartEsbChannel">
<jms-message-filter
dest-type="QUEUE"
dest-name="wsmq/SerivceOrderQueue"
/>
</jms-bus>
</jms-provider>
jboss-service.xml looks like this
<mbean code="jmx.service.wsmq.WSMQConnectionFactory"
name="jmx.service.wsmq:service=MQQueueConnectionFactory">
<attribute name="JndiName">MQQueueConnectionFactory</attribute>
<attribute name="JMSStyle">Queue</attribute>
<attribute name="IsXA">false</attribute>
<attribute name="QueueManagerName">SQAT0083</attribute>
<attribute name="HostName">111.111.111.111</attribute>
<attribute name="Port">1415</attribute>
<attribute name="Channel">MYCO.SVRCONN</attribute>
<attribute name="TransportType">CLIENT</attribute>
<depends>jboss:service=Naming</depends>
</mbean>
<mbean code="jmx.service.wsmq.WSMQDestination"
name="jmx.service.wsmq:service=WSMQRequestQueue">
<attribute name="JndiName">wsmq/SerivceOrderQueue</attribute>
<attribute name="JMSStyle">Queue</attribute>
<attribute name="QueueManagerName">SQAT0083</attribute>
<attribute name="DestinationName">MYCO.SERVICEORDER.QA01.QL01</attribute>
<attribute name="TargetClient">MQ</attribute>
<depends>jboss:service=Naming</depends>
</mbean>
I am using jboss-eap-4.3. Really appreciate any help.
Here is my Service Tag Looks like in jboss-esb.xml
<listeners>
<jms-listener name="MQ-Gateway"
busidref="queuestartGwChannel"
is-gateway="true" maxThreads="1"
/>
<jms-listener name="MQ-EsbListener" busidref="queuestartEsbChannel" />
</listeners>
<actions mep="OneWay">
<action name="serviceOrderMarshaller"
class="com.my.esb.actions.ServiceOrderMessageUnMarshallerAction"
process="unmarshalPayload">
<property name="springContextXml" value="spring/mainApplicationContext.xml"/>
</action>
<action name="serviceOrderStaging"
class="com.my.esb.actions.ServiceOrdersStagingAction"
process="stageServiceOrders">
<property name="springContextXml" value="spring/mainApplicationContext.xml"/>
</action>
<action name="marginAndLeadTimeRetriever"
class="com.my.esb.actions.MarginAndLeadTimeRetrieverAction"
process="retrieveJobCodeInfo">
<property name="springContextXml" value="spring/mainApplicationContext.xml"/>
</action>
<action name="createDraftRequestMapper"
class="com.my.esb.actions.CreateDraftRequestMapperAction"
process="mapData">
<property name="springContextXml" value="spring/mainApplicationContext.xml"/>
</action>
<action name="omsCreateDraftRequestTranslator"
class="com.my.esb.actions.OMSCreateDraftRequestTranslatorAction"
process="translateData">
<property name="springContextXml" value="spring/mainApplicationContext.xml"/>
</action>
<action name="createDraftRequestProcessor"
class="com.my.esb.actions.CreateDraftRequestProcessorAction"
process="dispatchRequest">
<property name="springContextXml" value="spring/mainApplicationContext.xml"/>
</action>
</actions>
Bit late response but if someone reads this, the answer is:
queuestartEsbChannel is listening to the same queue that is delivering jmstextmessages and it has is-gateway set to false (default value).
If is-gateway is false, only ESB messages can be recieved on that listener.
I would have expected to see com.ibm.mqjms.jar in the CLASSPATH for a JMS app, not com.ibm.mq.*.
Depending on the version of WMQ you are using, please reference the Environment Variables page in the Infocenter. WMQ V6 page is here (see Table #2), and the WMQ v7 page is here (see the table and the notes below). Note that the classes have been repackaged between versions and the CLASSPATH requirements are quite different.
On UNIX flavors, you can run the setmqjms script to configure the environment for WMQ JMS. It lives in /opt/mqm/java/bin or /usr/mqm/java/bin on AIX. This assumes a standard WMQ client installation, though. If you just grabbed the jars and relocated them, it won't work. In particular, if you just grabbed the com.ibm.mq* jars it likely won't work. You can verify your installation by running the Initial Verification Test (IVT) supplied with the client install. The additional benefit of using a full WMQ client is that all of the trace utilities and sample code and other diagnostics are installed.
One other piece of advice, be sure to use the WMQ v7 client even if the WMQ server is at v6. This is because WMQ v6 is going out of service next year and will not be supported after that. Using the v7 client now will save you a migration later, CLASSPATH changes, etc. In addition, the v7 classes have lots of cool new features when used with a v7 QMgr such as automatic client reconnection to the same or different QMgr, depending on your configuration. The WMQ client install is a free download (registration required) as SupportPac MQC7.