Java 将数据发送到Wildfly 10嵌入式Artemis实例,并使用Apache Camel将其接收回来
我正在尝试向Wildfly 10 Artemis实例发送一些数据,并使用ApacheCamel将它们接收回来。 在这里,我知道,这可以使用驼峰jms组件来完成 在本例中,首先我创建了一个简单的示例来检查这是否正常工作。 但它在ConnectionFactory创建点给出了以下异常Java 将数据发送到Wildfly 10嵌入式Artemis实例,并使用Apache Camel将其接收回来,java,apache-camel,jms,wildfly-10,activemq-artemis,Java,Apache Camel,Jms,Wildfly 10,Activemq Artemis,我正在尝试向Wildfly 10 Artemis实例发送一些数据,并使用ApacheCamel将它们接收回来。 在这里,我知道,这可以使用驼峰jms组件来完成 在本例中,首先我创建了一个简单的示例来检查这是否正常工作。 但它在ConnectionFactory创建点给出了以下异常 Exception in thread "main" javax.naming.NamingException: Failed to connect to any server. Servers tried: [htt
Exception in thread "main" javax.naming.NamingException: Failed to connect to any server. Servers tried: [http-remoting://localhost:8080]
at org.jboss.naming.remote.client.HaRemoteNamingStore.failOverSequence(HaRemoteNamingStore.java:213)
at org.jboss.naming.remote.client.HaRemoteNamingStore.namingStore(HaRemoteNamingStore.java:144)
at org.jboss.naming.remote.client.HaRemoteNamingStore.namingOperation(HaRemoteNamingStore.java:125)
at org.jboss.naming.remote.client.HaRemoteNamingStore.lookup(HaRemoteNamingStore.java:241)
at org.jboss.naming.remote.client.RemoteContext.lookup(RemoteContext.java:79)
at org.jboss.naming.remote.client.RemoteContext.lookup(RemoteContext.java:83)
at javax.naming.InitialContext.lookup(InitialContext.java:417)
实施:
Properties props = new Properties();
props.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");
props.put(Context.PROVIDER_URL, WILDFLY_REMOTING_URL);
props.put(Context.SECURITY_PRINCIPAL, JMS_USERNAME);
props.put(Context.SECURITY_CREDENTIALS, JMS_PASSWORD);
InitialContext context = new InitialContext(props);
ConnectionFactory connectionFactory = (QueueConnectionFactory) context.lookup(JMS_CONNECTION_FACTORY_JNDI);
System.out.println("connectionFactory : " + connectionFactory);
SimpleRouteBuilder routeBuilder = new SimpleRouteBuilder();
CamelContext ctx = new DefaultCamelContext();
ctx.addComponent("jms", JmsComponent.jmsComponentAutoAcknowledge(connectionFactory));
ctx.addRoutes(routeBuilder);
ctx.start();
Thread.sleep(5 * 60 * 1000);
ctx.stop();
public final static String JMS_CONNECTION_FACTORY_JNDI="jms/RemoteConnectionFactory";
public final static String JMS_QUEUE_JNDI="jms/queue/TestQ";
public final static String JMS_USERNAME="jmsuser"; // The role for this user is "guest" in ApplicationRealm
public final static String JMS_PASSWORD="jmsuser@123";
public final static String WILDFLY_REMOTING_URL="http-remoting://localhost:8080";
import java.util.Properties;
import javax.jms.ConnectionFactory;
import org.apache.camel.CamelContext;
import org.apache.camel.component.jms.JmsComponent;
import org.apache.camel.impl.DefaultCamelContext;
import javax.jms.QueueConnectionFactory;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
常数:
Properties props = new Properties();
props.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");
props.put(Context.PROVIDER_URL, WILDFLY_REMOTING_URL);
props.put(Context.SECURITY_PRINCIPAL, JMS_USERNAME);
props.put(Context.SECURITY_CREDENTIALS, JMS_PASSWORD);
InitialContext context = new InitialContext(props);
ConnectionFactory connectionFactory = (QueueConnectionFactory) context.lookup(JMS_CONNECTION_FACTORY_JNDI);
System.out.println("connectionFactory : " + connectionFactory);
SimpleRouteBuilder routeBuilder = new SimpleRouteBuilder();
CamelContext ctx = new DefaultCamelContext();
ctx.addComponent("jms", JmsComponent.jmsComponentAutoAcknowledge(connectionFactory));
ctx.addRoutes(routeBuilder);
ctx.start();
Thread.sleep(5 * 60 * 1000);
ctx.stop();
public final static String JMS_CONNECTION_FACTORY_JNDI="jms/RemoteConnectionFactory";
public final static String JMS_QUEUE_JNDI="jms/queue/TestQ";
public final static String JMS_USERNAME="jmsuser"; // The role for this user is "guest" in ApplicationRealm
public final static String JMS_PASSWORD="jmsuser@123";
public final static String WILDFLY_REMOTING_URL="http-remoting://localhost:8080";
import java.util.Properties;
import javax.jms.ConnectionFactory;
import org.apache.camel.CamelContext;
import org.apache.camel.component.jms.JmsComponent;
import org.apache.camel.impl.DefaultCamelContext;
import javax.jms.QueueConnectionFactory;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
导入:
Properties props = new Properties();
props.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");
props.put(Context.PROVIDER_URL, WILDFLY_REMOTING_URL);
props.put(Context.SECURITY_PRINCIPAL, JMS_USERNAME);
props.put(Context.SECURITY_CREDENTIALS, JMS_PASSWORD);
InitialContext context = new InitialContext(props);
ConnectionFactory connectionFactory = (QueueConnectionFactory) context.lookup(JMS_CONNECTION_FACTORY_JNDI);
System.out.println("connectionFactory : " + connectionFactory);
SimpleRouteBuilder routeBuilder = new SimpleRouteBuilder();
CamelContext ctx = new DefaultCamelContext();
ctx.addComponent("jms", JmsComponent.jmsComponentAutoAcknowledge(connectionFactory));
ctx.addRoutes(routeBuilder);
ctx.start();
Thread.sleep(5 * 60 * 1000);
ctx.stop();
public final static String JMS_CONNECTION_FACTORY_JNDI="jms/RemoteConnectionFactory";
public final static String JMS_QUEUE_JNDI="jms/queue/TestQ";
public final static String JMS_USERNAME="jmsuser"; // The role for this user is "guest" in ApplicationRealm
public final static String JMS_PASSWORD="jmsuser@123";
public final static String WILDFLY_REMOTING_URL="http-remoting://localhost:8080";
import java.util.Properties;
import javax.jms.ConnectionFactory;
import org.apache.camel.CamelContext;
import org.apache.camel.component.jms.JmsComponent;
import org.apache.camel.impl.DefaultCamelContext;
import javax.jms.QueueConnectionFactory;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
但是,当我使用纯javax.jms(不是通过Camel)时(如中所述),就会成功地实现这一点。当我直接向活动mq(而不是Wildfly Artemis)发送消息时,它可以成功地工作
我想知道的是,将数据发送到Wildfly嵌入式Artemis InsNance,然后使用ApacheCamel将数据接收回来。
有人能给点提示吗?您收到的错误是:
Failed to connect to any server. Servers tried: [http-remoting://localhost:8080]
这向我表明,您的Wildfly实例实际上并没有在localhost:8080上侦听JNDI连接。您没有包括任何Wildfly配置或日志记录,因此这只是一个猜测
您还说过,“当我直接向活动mq(而不是Wildfly Artemis)发送消息时,它会成功工作”,但不清楚这到底意味着什么。Apache ActiveMQ Artemis(顾名思义)是一个ActiveMQ代理,因此当您说您向“active mq”发送消息时,不清楚您指的是独立的Artemis(即未嵌入Wildfly)还是ActiveMQ 5.x代理
最后,将Artemis称为“Wildfly Artemis”可能有点误导,因为Artemis不是Wildfly项目,而是Apache项目。我假设“Wildfly Artemis”实际上是指“嵌入Wildfly中的ActiveMQ Artemis”。您收到的错误是:
Failed to connect to any server. Servers tried: [http-remoting://localhost:8080]
这向我表明,您的Wildfly实例实际上并没有在localhost:8080上侦听JNDI连接。您没有包括任何Wildfly配置或日志记录,因此这只是一个猜测
您还说过,“当我直接向活动mq(而不是Wildfly Artemis)发送消息时,它会成功工作”,但不清楚这到底意味着什么。Apache ActiveMQ Artemis(顾名思义)是一个ActiveMQ代理,因此当您说您向“active mq”发送消息时,不清楚您指的是独立的Artemis(即未嵌入Wildfly)还是ActiveMQ 5.x代理
最后,将Artemis称为“Wildfly Artemis”可能有点误导,因为Artemis不是Wildfly项目,而是Apache项目。我想“Wildfly Artemis”的意思是“嵌入Wildfly的ActiveMQ Artemis。”@Justin,谢谢你的回答。很抱歉我的问题中有不清楚的地方。在这种情况下,提到“ActiveMQ diretly”意味着发送到独立的activemq5.x代理。是的,提到Wildfly Artemis,我指的是嵌入Wildfly的ActiveMQ Artemis。@Justin,谢谢你的回答。很抱歉我的问题中有不清楚的地方。在这种情况下,提到“ActiveMQ diretly”意味着发送到独立的activemq5.x代理。是的,提到Wildfly Artemis,我指的是嵌入Wildfly中的ActiveMQ Artemis。