Inserting Qpid Proton 0.10 in to HornetQ 2.4.0.Final -- possible?
mattrk Oct 19, 2015 12:37 PMHello,
I am presently trying to insert Qpid Proton 0.10 in to HornetQ 2.4.0.Final.
I have tried multiple approaches but whenever I try to establish either the session or connection I run
into fatal problems (in the example below, the code "hangs" with no error message when establishing the
session).
I will explain one of my approaches in the hope that someone may have some idea what is
going on. If anyone has any pointers they would be much appreciated.
Steps:
1) Rename HornetQ's proton-j-impl.jar to proton-j-impl.jar.old (in "C:\Messaging\hornetq-2.4.0.Final\lib")
2) Insert Qpid Proton 0.10 as proton-j-impl.jar
3) Set up the config files in "C:\Messaging\hornetq-2.4.0.Final\config\stand-alone\non-clustered" (as supplied below; based on the ProtonJ example config files).
4) Run server
5) Copy the basic AMQP example from Artemis
6) Adapt it.
7) Run example.
Any suggestions? Any clarifications/more info needed?
Thank you & regards,
Matthew
#####################
# hornetq-beans.xml #
#####################
<?xml version="1.0" encoding="UTF-8"?>
<deployment xmlns="urn:jboss:bean-deployer:2.0">
<!-- MBean server -->
<bean name="MBeanServer" class="javax.management.MBeanServer">
<constructor factoryClass="java.lang.management.ManagementFactory"
factoryMethod="getPlatformMBeanServer"/>
</bean>
<!-- The core configuration -->
<bean name="Configuration" class="org.hornetq.core.config.impl.FileConfiguration">
</bean>
<!-- The security manager -->
<bean name="HornetQSecurityManager" class="org.hornetq.spi.core.security.HornetQSecurityManagerImpl">
<start ignored="true"/>
<stop ignored="true"/>
</bean>
<!-- The core server -->
<bean name="HornetQServer" class="org.hornetq.core.server.impl.HornetQServerImpl">
<constructor>
<parameter>
<inject bean="Configuration"/>
</parameter>
<parameter>
<inject bean="MBeanServer"/>
</parameter>
<parameter>
<inject bean="HornetQSecurityManager"/>
</parameter>
</constructor>
<start ignored="true"/>
<stop ignored="true"/>
</bean>
<!-- The JMS server -->
<bean name="JMSServerManager" class="org.hornetq.jms.server.impl.JMSServerManagerImpl">
<constructor>
<parameter>
<inject bean="HornetQServer"/>
</parameter>
</constructor>
</bean>
</deployment>
#############################
# hornetq-configuration.xml #
#############################
<configuration xmlns="urn:hornetq"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:hornetq /schema/hornetq-configuration.xsd">
<bindings-directory>${build.directory}/server0/data/messaging/bindings</bindings-directory>
<journal-directory>${build.directory}/server0/data/messaging/journal</journal-directory>
<large-messages-directory>${build.directory}/server0/data/messaging/largemessages</large-messages-directory>
<paging-directory>${build.directory}/server0/data/messaging/paging</paging-directory>
<!-- Acceptors -->
<acceptors>
<acceptor name="proton-acceptor">
<factory-class>org.hornetq.core.remoting.impl.netty.NettyAcceptorFactory</factory-class>
<param key="protocol" value="AMQP"/>
<param key="port" value="5672"/>
</acceptor>
</acceptors>
<queues>
<queue name="testQueue">
<address>testQueue</address>
</queue>
</queues>
<!-- Other config -->
<security-settings>
<!--security for example queue-->
<security-setting match="testQueue">
<permission type="createDurableQueue" roles="guest"/>
<permission type="deleteDurableQueue" roles="guest"/>
<permission type="createNonDurableQueue" roles="guest"/>
<permission type="deleteNonDurableQueue" roles="guest"/>
<permission type="consume" roles="guest"/>
<permission type="send" roles="guest"/>
</security-setting>
</security-settings>
</configuration>
###################
# hornetq-jms.xml #
###################
<configuration xmlns="urn:hornetq"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:hornetq /schema/hornetq-jms.xsd">
</configuration>
#####################
# hornetq-users.xml #
#####################
<configuration xmlns="urn:hornetq" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:hornetq /schema/hornetq-users.xsd">
<!-- the default user. this is used where username is null-->
<defaultuser name="guest" password="guest">
<role name="guest"/>
</defaultuser>
</configuration>
######################
# logging.properties #
######################
handlers=java.util.logging.ConsoleHandler
java.util.logging.ConsoleHandler.formatter=org.hornetq.integration.logging.HornetQLoggerFormatter
java.util.logging.FileHandler.level=INFO
java.util.logging.FileHandler.formatter=org.hornetq.integration.logging.HornetQLoggerFormatter
java.util.logging.FileHandler.pattern=logs/hornetq.log
.level= INFO
#########################
# AMQPQueueExample.java #
#########################
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package matt_protonj;
import javax.jms.Connection;
import javax.jms.ConnectionFactory;
import javax.jms.MessageConsumer;
import javax.jms.MessageProducer;
import javax.jms.Queue;
import javax.jms.Session;
import javax.jms.TextMessage;
import org.apache.qpid.jms.JmsConnectionFactory;
public class AMQPQueueExample {
public static void main(String[] args) throws Exception {
Connection connection = null;
ConnectionFactory connectionFactory = new JmsConnectionFactory("amqp://localhost:5672");
try {
System.out.println("Step 1. Create an amqp qpid 1.0 connection");
connection = connectionFactory.createConnection("guest","guest");
System.out.println("Step 2. Create a session");
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
System.out.println("Step 3. Create a sender");
Queue queue = session.createQueue("testQueue");
MessageProducer sender = session.createProducer(queue);
System.out.println("Step 4. send a few simple message");
sender.send(session.createTextMessage("Hello world "));
connection.start();
System.out.println("Step 5. create a moving receiver, this means the message will be removed from the queue");
MessageConsumer consumer = session.createConsumer(queue);
System.out.println("Step 7. receive the simple message");
TextMessage m = (TextMessage) consumer.receive(5000);
System.out.println("message = " + m.getText());
}
finally {
if (connection != null) {
System.out.println("Step 9. close the connection");
connection.close();
}
}
}
}