[英]MQ Pure Java Client Lib
I am evaluating Websphere MQ7. 我正在评估Websphere MQ7。 I am a traditionally a TibRV guy.
我传统上是TibRV家伙。 One thing I do not like is the fact that the IBM java client libs require C++ libs in order to run.
我不喜欢的一件事是,IBM Java客户端库需要C ++库才能运行。 Is there anyway to run the IBM java client libs without requiring the C++ libs?
无论如何,无需C ++库就可以运行IBM Java客户端库? eg is there a pure java client library for MQ ?
例如,是否有用于MQ的纯Java客户端库?
I have previously written a JMS client to MQSeries v6 (not your version, I know) without needing to install native libs. 以前,我已经为MQSeries v6(我知道不是您的版本)编写了一个JMS客户端,而无需安装本机库。 The only IBM libraries I required were titled:
我所需的唯一IBM库的标题为:
According to this post they come with the client install. 根据这篇文章,它们与客户端安装一起提供。 I assume you can install it once, then re-use the jars (any licensing issues and expert opinions aside).
我假设您可以安装一次,然后重新使用广口瓶(不考虑任何许可问题和专家意见)。
EDIT: In response to your comment, here's the client code I hacked up. 编辑:为了回应您的评论,这是我黑客攻击的客户端代码。 It is for reading messages from a queue and blatting them to files.
它用于从队列中读取消息并将其归类到文件中。 It's written in Scala.
它是用Scala编写的。 I hope it helps somewhat.
我希望它能有所帮助。
import com.ibm.mq._
import java.text._
import java.io._
case class QueueDetails(hostname: String, channel: String,
port: Int, queueManager: String, queue: String)
class Reader(details: QueueDetails) {
def read = {
MQEnvironment.hostname = details.hostname
MQEnvironment.channel = details.channel
MQEnvironment.port = details.port
val props = new java.util.Hashtable[String, String]
props.put(MQC.TRANSPORT_PROPERTY, MQC.TRANSPORT_MQSERIES)
MQEnvironment.properties = props
val qm = new MQQueueManager(details.queueManager)
val options = MQC.MQOO_INPUT_AS_Q_DEF | MQC.MQOO_INQUIRE
val q = qm.accessQueue(details.queue, options, null, null, null)
val depth = q.getCurrentDepth
val indexFormat = new DecimalFormat(depth.toString.replaceAll(".", "0"))
def exportMessage(index: Int): Unit = {
if (index < depth) {
val msg = new MQMessage
q.get(msg, new MQGetMessageOptions)
val msgLength = msg.getMessageLength
val text = msg.readStringOfByteLength(msgLength)
val file = new File("message_%s.txt".format(indexFormat.format(index)))
val writer = new BufferedWriter(new FileWriter(file))
writer.write(text)
writer.close
println(file.getAbsolutePath)
exportMessage(index + 1)
}
}
exportMessage(0)
q.close
qm.disconnect
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.