Good Day
I would just like to ask some help / clarification as well since I am new in implementing JMS, I've already been to the following link
"Failed to create session factory" from client connecting to jboss-as7 hornetq
[HORNETQ-952] When binding AS to 0.0.0.0 remote HornetQ clients fail - JBoss Issue Tracker
https://issues.jboss.org/browse/JBPAPP-9393
May I ask how do you do JMS Queue remoting on JBOss 7.1.1.Final
I'm using RemoteConnectionFactory in my connection
Do I need to bind my remote(172.45.45.45) jboss server to a specific IP address in order to connect to it remotely? Like passing a –b IPAddress upon starting jboss?
or configuring it on standalone.conf like this
And in remote IP /jboss/bin/standalone.conf (do I really need this?)
# set this value so we can send JMS messages from remote clients
JAVA_OPTS="$JAVA_OPTS -Djboss.bind.address=172.45.45.45”
Here is a scenario I wanted to send a JMS message to my Queue in my local laptop, I have a publisher for my queue and on 172.45.45.45 (remote ip) web.war() is deployed in that remote IP and I have my consumer configured to this queue
<jms-queue name=“testqueue">
<entry name="java:jboss/queue/mss/testqueue"/>
<durable>true</durable>
</jms-queue>
I have configured my Jboss application user with the guest role
I have my queue config in standalone.xml(copy of standalone-full.xml)
I have my JMS publisher/consumer
If I have the following config below, sending JMS message remotely is working fine. Without that I’m getting a error=2 cannot connect to server(s)
my local etc/hosts config for that IP (do I really need this?)
enter code here
172.45.45.45 ip-172-45-45-45.ec2.internal
remote Jboss server config
And in remote IP /jboss/bin/standalone.conf (do I really need this?)
#set this value so we can send JMS messages from remote clients
JAVA_OPTS="$JAVA_OPTS -Djboss.bind.address=172.45.45.45”
BTW i followed this tutorial
http://theopentutorials.com/examples/java-ee/ejb3/remote-jms-client-and-ejb3-mdb-consumer-eclipse-jboss-7-1/
Need help on implementing JMS queue remotely without the following configuration
my local etc/hosts config for that IP (do I really need this?)
172.45.45.45 ip-172-45-45-45.ec2.internal
remote Jboss server config
And in remote IP /jboss/bin/standalone.conf (do I really need this?)
#set this value so we can send JMS messages from remote clients
JAVA_OPTS="$JAVA_OPTS -Djboss.bind.address=172.45.45.45”
Here is the Code snippet for my JMS Publisher
private static String username = "testuser";
private static String password = "testpass";
private static String host = "remote://172.45.45.45:4447";
Properties jndiProps = new Properties();
try {
jndiProps.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");
jndiProps.put(Context.PROVIDER_URL, host);
jndiProps.put(Context.SECURITY_PRINCIPAL, username);
jndiProps.put(Context.SECURITY_CREDENTIALS, password);
Context context = new InitialContext(jndiProps);
ConnectionFactory connectionFactory = (ConnectionFactory) context.lookup("jms/RemoteConnectionFactory");
connection = connectionFactory.createConnection(username, password);
topic = (Topic) context.lookup("jms/topic/testTopic");
System.out.println("Connected to JMS");
connection.start();
Sample Code snippet from my Consumer
/**
* Message-Driven Bean implementation class for: MDBSample- This is for Consume the Queue
*/
#MessageDriven(activationConfig = {#ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
#ActivationConfigProperty(propertyName = "destination", propertyValue = "java:/queue/test"),
#ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge")})
public class MessageConsumer implements MessageListener {
/**
* Default constructor.
*/
public MessageConsumer() {
}
/**
* #see MessageListener#onMessage(Message)
*/
public void onMessage(Message message) {
try {
ObjectMessage msg = (ObjectMessage) message;
JMSMessage jmsMessage = (JMSMessage) msg.getObject();
System.out.println("Received message is ==========> " + jmsMessage.getAction());
} catch (JMSException e) {
e.printStackTrace();
}
}
}
Any Ideas or suggestion?
Related
I have an embedded ActiveMQ Artemis 2.17.0 broker that has no pre-configured queues. I'd like for the client to connect to the broker and have its queue created automatically if it doesn't exist. This works just fine the 1st time when I run the client but on the second time I connect again to the broker the client throws an error :
errorType=QUEUE_EXISTS message=AMQ229019: Queue hornetq already exists on address router
Is it possible to configure the client or the server in such a way that if a queue is already in existence it should not attempt to recreate it again?
Below are the programs I am running:
Server
try {
ActiveMQServer server = new ActiveMQServerImpl(new ConfigurationImpl()
.setPersistenceEnabled(true)
.setBindingsDirectory("./router/data/bindings")
.setLargeMessagesDirectory("./router/data/large")
.setPagingDirectory("./router/data/paging")
.setJournalDirectory("./router/data/journal")
.setSecurityEnabled(false)
.addAcceptorConfiguration("tcp", "tcp://0.0.0.0:61617?protocols=CORE,AMQP"));
server.start();
} catch (Exception ex) {
System.err.println(ex);
}
Client
ServerLocator serverLocator = ActiveMQClient.createServerLocator("tcp://127.0.0.1.3:61617");
ClientSessionFactory factory = serverLocator.createSessionFactory();
ClientSession session = factory.createSession();
session.createQueue(new QueueConfiguration("router::hornetq")
.setAutoCreateAddress(Boolean.FALSE)
.setAutoCreated(Boolean.FALSE)
.setRoutingType(RoutingType.ANYCAST));
ClientProducer producer = session.createProducer("router::hornetq");
ClientMessage message = session.createMessage(true);
message.getBodyBuffer().writeString("Core Queue Message");
producer.send(message);
session.start();
ClientConsumer consumer = session.createConsumer("router::hornetq");
ClientMessage msgReceived = consumer.receive();
System.out.println("message = " + msgReceived.getBodyBuffer().readString());
session.close();
I'm using the fully qualified queue name here (i.e. router::hornetq) because I have multiple queues on the router address.
Your client is using the core API which is a low-level API that does not support auto-queue creation. Your client is creating (or attempting to create) the queue manually, e.g.:
session.createQueue(new QueueConfiguration("router::hornetq")
.setAutoCreateAddress(Boolean.FALSE)
.setAutoCreated(Boolean.FALSE)
.setRoutingType(RoutingType.ANYCAST));
The exception you're seeing is no doubt being thrown here if the queue exists already. Creating a queue is not idempotent so you have 3 options from what I can see:
Simply catch the ActiveMQQueueExistsException that is being thrown here and ignore it.
Use ClientSession.queueQuery to see if the queue exists before you attempt to create it. If it exists then don't try to create it again. If it doesn't exist then create it. That said, if you have lots of clients like this running concurrently it's still possible you could get an ActiveMQQueueExistsException due to race conditions between the clients.
Use a client/protocol that supports auto-creation like the core JMS client or AMQP.
A few other things are worth mentioning:
Since you're not explicitly calling ClientSession.createAddress() you probably want to use setAutoCreateAddress(Boolean.TRUE).
Your consumer doesn't have to use router::hornetq. It can just use hornetq and it will receive any messages sent to the hornetq queue. Queue names are universally unique in the broker.
I am trying to implement an interface for my erlang program using jinterface. When I call the command OtpNode otpNode = new OtpNode(nodeName, cookie); java throws an IOException with
java.io.IOException: Nameserver not responding on DESKTOP-GIR29G3 when publishing javanode.
It doesn't seem to be common problem for people as I couldn't find anything similar online. It's a local node with the node name being "javanode" with no fullstops or dashes. Why would there be a DNS issue on a local node?
I have tried starting an erlang node in the directory the java program is started as well as starting the erlang console on my pc, but I'm very new to erlang so those were just wild guesses that some erlang VM must be running.
Here is the code that may help:
public Erlterface()
{
Thread t = new Thread(new Runnable() {
public void run() {
setupMBox();
}
});
t.start();
}
private void setupMBox()
{
try {
String nodeName = "javanode";
String cookie = "jinterface";
//String[] names = OtpEpmd.lookupNames();
OtpNode otpNode = new OtpNode(nodeName, cookie); //CRASH HAPPENS HERE
OtpMbox Mbox = otpNode.createMbox("javaserver");
The error from the console:
Connected to the target VM, address: '127.0.0.1:54025', transport: 'socket'
java.io.IOException: Nameserver not responding on DESKTOP-GIR29G3 when publishing javanode
at com.stellar.base.schedule.com.ericsson.otp.erlang.OtpEpmd.r4_publish(OtpEpmd.java:344)
at com.stellar.base.schedule.com.ericsson.otp.erlang.OtpEpmd.publishPort(OtpEpmd.java:141)
at com.stellar.base.schedule.com.ericsson.otp.erlang.OtpNode$Acceptor.publishPort(OtpNode.java:784)
at com.stellar.base.schedule.com.ericsson.otp.erlang.OtpNode$Acceptor.<init>(OtpNode.java:776)
at com.stellar.base.schedule.com.ericsson.otp.erlang.OtpNode.init(OtpNode.java:232)
at com.stellar.base.schedule.com.ericsson.otp.erlang.OtpNode.<init>(OtpNode.java:196)
at com.stellar.base.schedule.com.ericsson.otp.erlang.OtpNode.<init>(OtpNode.java:149)
at com.stellar.base.schedule.Erlterface.setupMBox(Erlterface.java:40)
at com.stellar.base.schedule.Erlterface.access$000(Erlterface.java:16)
at com.stellar.base.schedule.Erlterface$1.run(Erlterface.java:26)
at java.lang.Thread.run(Thread.java:745)
Thanks in advance
Dale
UPDATE ADDITIONAL INFORMATION:
I went into a dive to try and figure out where exactly the train leaves the rails but I'm taking wild guesses as to what I should flag as potential issues. I just want to add some additional information here to help:
In OptEpmd the following is caught before the io exception is thrown
java.net.ConnectException: Connection refused: connect
The final source is the native DeulSocketImpl class that I suppose calls on windows to do the final connection thingamabob ad it fails:
static native int connect0(int var0, InetAddress var1, int var2) throws IOException;
Am I missing something in setting up the erlang node? I surely don't have to start it manually? I've diabled my firewall completely to test it. How do I figure out why the connection was refused?
When I am trying to connect solace VMR Server and deliver the messages from a Java client called Vertx AMQP Bridge.
I am able to connect the Solace VMR Server but after connecting, not able to send messages to solace VMR.
I am using below sender code from vertx client.
public class Sender extends AbstractVerticle {
private int count = 1;
// Convenience method so you can run it in your IDE
public static void main(String[] args) {
Runner.runExample(Sender.class);
}
#Override
public void start() throws Exception {
AmqpBridge bridge = AmqpBridge.create(vertx);
// Start the bridge, then use the event loop thread to process things thereafter.
bridge.start("13.229.207.85", 21196,"UserName" ,"Password", res -> {
if(!res.succeeded()) {
System.out.println("Bridge startup failed: " + res.cause());
return;
}
// Set up a producer using the bridge, send a message with it.
MessageProducer<JsonObject> producer =
bridge.createProducer("T/GettingStarted/pubsub");
// Schedule sending of a message every second
System.out.println("Producer created, scheduling sends.");
vertx.setPeriodic(1000, v -> {
JsonObject amqpMsgPayload = new JsonObject();
amqpMsgPayload.put(AmqpConstants.BODY, "myStringContent" + count);
producer.send(amqpMsgPayload);
System.out.println("Sent message: " + count++);
});
});
}
}
I am getting the error below:
Bridge startup failed: io.vertx.core.impl.NoStackTraceThrowable:
Error{condition=amqp:not-found, description='SMF AD bind response
error', info={solace.response_code=503, solace.response_text=Unknown
Queue}} Apr 27, 2018 3:07:29 PM io.vertx.proton.impl.ProtonSessionImpl
WARNING: Receiver closed with error
io.vertx.core.impl.NoStackTraceThrowable:
Error{condition=amqp:not-found, description='SMF AD bind response
error', info={solace.response_code=503, solace.response_text=Unknown
Queue}}
I have created queue and also topic correctly in solace VMR but not able to send/receive messages. Am I missing any configuration from solace VMR Server side? Is there any code-change required in the Vertx Sender Java code above? I am getting the error trace above when delivering message. Can someone help on the same?
Vertx AMQP Bridge Java client :https://vertx.io/docs/vertx-amqp-bridge/java/
There are a few different reason why you may be encountering this error.
It could be that the client is not authorized to publish guaranteed messages. To fix this, you need to enable "guaranteed endpoint create" in the client-profile on the Solace router side.
It may also be that the application is using Reply Handling. This is not currently supported with the Solace router. Support for this will be added in the 8.11 release of the Solace VMR. A workaround for this would be to set ReplyHandlingSupport to false.
AmqpBridgeOptions().setReplyHandlingSupport(false);
There is also a known issue in the Solace VMR which causes this error when unsubscribing from a durable topic endpoint. A fix for this issue will also be in the 8.11 release of the Solace VMR. A workaround for this is to disconnect the client without first unsubscribing.
I am using the Jersey 2.25.1 Client and can't get any log output. I've looked at the 2.25.1 documentation -
https://www.scribd.com/document/350321996/Jersey-Documentation-2-25-1-User-Guide
- and followed what they described for Client logging -
ClientConfig clientConfig = new ClientConfig();
clientConfig.property(LoggingFeature.LOGGING_FEATURE_VERBOSITY_CLIENT, LoggingFeature.Verbosity.PAYLOAD_ANY);
Client client = ClientBuilder.newClient(clientConfig);
Is there an addition step that I am missing? The request is working as expected. The application is running on a Glassfish server and using SLF4J. My understanding was that the output would be logged to the server.log.
You also need to register a logging Filter
clientConfig.register(new MyLogFilter());
You need to create a log filter
class MyLogFilter implements ClientRequestFilter {
private static final Logger LOG = Logger.getLogger(MyLogFilter.class.getName());
#Override
public void filter(ClientRequestContext requestContext) throws IOException {
LOG.log(Level.INFO, requestContext.getEntity().toString()); // you can configure logging level here
}
}
I'm new to Zookeeper. I have created a node in the zookeeper server in standalone mode. Here is the code snippet for that.
public Connect(String hostPort, String znode, String filename) throws KeeperException, IOException, InterruptedException {
this.filename = filename;
zk = new ZooKeeper(hostPort, 3000, this);
zk.create(znode, new byte[0],
ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
}
Now I want to give authentication requirements using SASL in DIGEST-MD5 mode when I create the node (in the above code). I have successfully configured required configurations in the Zookeeper server hosted and have not configured in the Client.
Thanks in advance.
I found a way to enable sasl authentication for zookeeper nodes.
Here is the code I used.
zk.addAuthInfo("digest", "admin:admin".getBytes());