简体   繁体   English

将消息从Java放入队列

[英]Put message into queue from Java

I am trying to put a message into queue from my Java code(in my local machine). 我试图将消息从我的Java代码(在本地计算机中)放入队列中。 I am getting the error: 我收到错误消息:

java.lang.UnsatisfiedLinkError: no mqjbnd05 in java.library.path. java.lang.UnsatisfiedLinkError:java.library.path中没有mqjbnd05。

This is my code : 这是我的代码:

qMgr = new MQQueueManager(qManager);
int openOptions = MQC.MQOO_INPUT_AS_Q_DEF | MQC.MQOO_OUTPUT ;

MQQueue queue = qMgr.accessQueue("Q1",openOptions); 
MQMessage msg = new MQMessage();
msg.writeUTF("this is a test message"); 

MQPutMessageOptions pmo = new MQPutMessageOptions();
queue.put(msg, pmo); 

MQMessage retrievedMessage = new MQMessage();
retrievedMessage.messageId = msg.messageId;

MQGetMessageOptions gmo = new MQGetMessageOptions();
queue.get(retrievedMessage, gmo);
String msgText = retrievedMessage.readUTF();
System.out.println("The message is: " + msgText);

queue.close();
qMgr.disconnect();

My Queue Manager is QM_FORD and queue name is Q1. 我的队列管理器是QM_FORD ,队列名称是Q1。 Listener port is 1414. The environment variables are set properly. 侦听器端口为1414。正确设置了环境变量。 Can anyone please guide me on this? 有人可以指导我吗?

The problem is not in your Java code. 问题不在您的Java代码中。 Unsatisfied Link Error means a native library (.dll in Windows, .so in Unix) is not being found. 不满意的链接错误表示未找到本机库(Windows中为.dll,在Unix中为.so)。 It's either missing, or not referenced in an environment variable: PATH (Windows) or LD_LIBRARY_PATH or LIBPATH, etc, depending on what operating system this is in. 它可能丢失,或者在以下环境变量中未引用:PATH(Windows)或LD_LIBRARY_PATH或LIBPATH等,具体取决于所使用的操作系统。

googling may give you a few ideas 谷歌搜索可能会给您一些想法

The problem here is the missing LIBRARY PATH. 这里的问题是缺少库路径。 Set your LD_LIBRARY_PATH to "MQ_INSTALLATION_DIR"/java/lib (For Unix) 将您的LD_LIBRARY_PATH设置为“ MQ_INSTALLATION_DIR” / java / lib(对于Unix)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM