本文整理汇总了Java中com.ibm.msg.client.wmq.WMQConstants类的典型用法代码示例。如果您正苦于以下问题:Java WMQConstants类的具体用法?Java WMQConstants怎么用?Java WMQConstants使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
WMQConstants类属于com.ibm.msg.client.wmq包,在下文中一共展示了WMQConstants类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: init
import com.ibm.msg.client.wmq.WMQConstants; //导入依赖的package包/类
public void init() throws InitException {
try {
MQConnectionFactory realfactory = new MQConnectionFactory();
realfactory.setTransportType(WMQConstants.WMQ_CM_CLIENT);
realfactory.setHostName(getHost());
realfactory.setPort(getPort());
realfactory.setQueueManager(getQueueManager());
realfactory.setChannel(getChannel());
factory = realfactory;
connection = factory.createConnection(getUser(), getPassword());
session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
dest = (getDestType() == DestType.QUEUE) ? session.createQueue(getDestination()) : session.createTopic(getDestination());
producer = session.createProducer(dest);
connection.start();
} catch (JMSException e) {
throw new InitException(e.fillInStackTrace());
}
}
开发者ID:matthiaskaiser,项目名称:jmet,代码行数:22,代码来源:WebSphereMQTarget.java
示例2: buildAMQPResources
import com.ibm.msg.client.wmq.WMQConstants; //导入依赖的package包/类
public void buildAMQPResources() throws Exception {
if (useJMS) {
// Use JMS to send messages to a topic.
JmsFactoryFactory ff = JmsFactoryFactory.getInstance(JmsConstants.WMQ_PROVIDER);
JmsConnectionFactory cf = ff.createConnectionFactory();
cf.setIntProperty(WMQConstants.WMQ_CONNECTION_MODE, WMQConstants.WMQ_CM_BINDINGS);
cf.setStringProperty(WMQConstants.WMQ_QUEUE_MANAGER, "PERF0");
jmsConnection = cf.createConnection();
jmsConnection.start();
Session jmsSession = jmsConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
Topic jmsTopic = jmsSession.createTopic(inboundTopic);
jmsProducer = jmsSession.createProducer(jmsTopic);
jmsMessage = jmsSession.createBytesMessage();
jmsMessage.writeBytes(message.getBytes());
}
else {
super.buildAMQPResources();
}
}
开发者ID:ot4i,项目名称:perf-harness,代码行数:20,代码来源:FloodPublisher.java
示例3: sendTextMessage
import com.ibm.msg.client.wmq.WMQConstants; //导入依赖的package包/类
public String sendTextMessage(String queueName, String msg) throws Exception {
if (StringUtils.isBlank(queueName)) {
throw new IllegalArgumentException("Queue can not be null!");
}
if (logger.isDebugEnabled()) {
StringBuilder sb = new StringBuilder();
sb.append("sendTextMessage :: Setting params... \n");
sb.append("\t- queueManagerName = '{}' \n");
sb.append("\t- queueName = '{}' \n");
sb.append("\t- replyToQueueName = '{}' \n");
sb.append("\t- hostname = '{}' \n");
sb.append("\t- port = '{}' \n");
sb.append("\t- channel = '{}' \n");
LoggerUtils.logDebug(logger, sb.toString(), queueManagerName, queueName, responseQueueName, hostname, port,
channel);
}
QueueConnection connection = null;
TextMessage requestMessage;
try {
QueueConnectionFactory qcf = new MQQueueConnectionFactory();
((MQQueueConnectionFactory) qcf).setIntProperty(WMQConstants.WMQ_CONNECTION_MODE,
WMQConstants.WMQ_CM_CLIENT);
((MQQueueConnectionFactory) qcf).setHostName(hostname);
((MQQueueConnectionFactory) qcf).setPort(port);
((MQQueueConnectionFactory) qcf).setQueueManager(queueManagerName);
if (StringUtils.isNotBlank(channel)) {
((MQQueueConnectionFactory) qcf).setChannel(channel);
}
// ((MQQueueConnectionFactory) qcf).setCCSID(500);
connection = qcf.createQueueConnection(" ", " ");
connection.start();
// Create a session
MQQueueSession session = (MQQueueSession) connection.createQueueSession(false, Session.CLIENT_ACKNOWLEDGE);
// Get a request queue
Queue queue = ((MQQueueSession) session).createQueue("queue://" + queueManagerName + "/" + queueName);
// Create message sender
QueueSender sender = session.createSender(queue);
requestMessage = session.createTextMessage(msg);
// m1.setIntProperty("JMS_", MQC.MQENC_NATIVE);
// Setting reply-to queue
Queue queueResp = ((MQQueueSession) session)
.createQueue("queue://" + queueManagerName + "/" + responseQueueName);
requestMessage.setJMSReplyTo(queueResp);
LoggerUtils.logDebug(logger, "sendTextMessage :: message \n{}", requestMessage.toString());
sender.send(requestMessage);
LoggerUtils.logDebug(logger, "sendTextMessage :: Message Sent! ID: {} \n",
requestMessage.getJMSMessageID());
return requestMessage.getJMSMessageID();
} finally {
if (connection != null) {
try {
connection.close();
} catch (JMSException je) {
je.printStackTrace();
}
}
}
}
开发者ID:dalifreire,项目名称:mq-gateway,代码行数:73,代码来源:MQGatewayImpl.java
示例4: receiveTextMessage
import com.ibm.msg.client.wmq.WMQConstants; //导入依赖的package包/类
/**
* Recupera as mensagens da fila de reponse de acordo com o messageID passado como parametro.
*
* @param messageID
* @return String
* @throws JMSException
*/
public String receiveTextMessage(String messageID) throws JMSException {
if (StringUtils.isEmpty(messageID)) {
throw new IllegalArgumentException(BundleMenssageUtils.getMensagem("mensagem.selector.null"));
}
if (StringUtils.isBlank(this.responseQueueName)) {
throw new IllegalArgumentException(BundleMenssageUtils.getMensagem("mensagem.fila.response.null"));
}
LoggerUtils.logDebug(logger, "receiveTextMessage :: Selecting response message using: '{}'", messageID);
String resMessage = null;
long finishTime = System.currentTimeMillis() + totalTimeOut;
while (StringUtils.isBlank(resMessage) && (System.currentTimeMillis() < finishTime)) {
QueueConnection connection = null;
TextMessage receivedMessage;
try {
QueueConnectionFactory qcf = new MQQueueConnectionFactory();
((MQQueueConnectionFactory) qcf).setIntProperty(WMQConstants.WMQ_CONNECTION_MODE,
WMQConstants.WMQ_CM_CLIENT);
((MQQueueConnectionFactory) qcf).setHostName(hostname);
((MQQueueConnectionFactory) qcf).setPort(port);
((MQQueueConnectionFactory) qcf).setQueueManager(queueManagerName);
if (StringUtils.isNotBlank(channel)) {
((MQQueueConnectionFactory) qcf).setChannel(channel);
}
// ((MQQueueConnectionFactory) qcf).setCCSID(500);
connection = qcf.createQueueConnection();
connection.start();
// Create a session
MQQueueSession session = (MQQueueSession) connection.createQueueSession(false,
Session.CLIENT_ACKNOWLEDGE);
// Get a response queue
Queue responseQueue = ((MQQueueSession) session)
.createQueue("queue://" + queueManagerName + "/" + responseQueueName);
MQQueueReceiver receiver = (MQQueueReceiver) session.createReceiver(responseQueue);
receivedMessage = (TextMessage) receiver.receive(totalTimeOut);
if (receivedMessage != null) {
resMessage = receivedMessage.getText();
receivedMessage.acknowledge();
LoggerUtils.logDebug(logger, "receiveTextMessage :: Response = '{}' \n", resMessage);
}
} finally {
if (connection != null) {
try {
connection.close();
} catch (JMSException je) {
je.printStackTrace();
}
}
}
}
return resMessage;
}
开发者ID:dalifreire,项目名称:mq-gateway,代码行数:72,代码来源:MQGatewayImpl.java
示例5: getMsgCompList
import com.ibm.msg.client.wmq.WMQConstants; //导入依赖的package包/类
/**
* 压缩集合,采用服务器——服务器方式和人行连接,不需要设置
* 在通道的发送通道和接收通道设置压缩格式
* @return
*/
@SuppressWarnings("unchecked")
public static Collection getMsgCompList(){
ArrayList msgComp = new ArrayList();
msgComp.add(new Integer( WMQConstants.WMQ_COMPMSG_ZLIBFAST));
msgComp.add(new Integer(WMQConstants.WMQ_COMPMSG_RLE ));
msgComp.add(new Integer(WMQConstants.WMQ_COMPMSG_ZLIBHIGH));
msgComp.add(new Integer(WMQConstants.WMQ_COMPHDR_NONE));
msgComp.add(new Integer(WMQConstants.WMQ_COMPMSG_DEFAULT));
return msgComp;
}
开发者ID:dreajay,项目名称:jcode,代码行数:16,代码来源:MQUtil.java
示例6: getHdrCompList
import com.ibm.msg.client.wmq.WMQConstants; //导入依赖的package包/类
/**
* 数据压缩分为消息头压缩和消息本身压缩
* @return
*/
@SuppressWarnings("unchecked")
public static Collection getHdrCompList(){
ArrayList msgComp = new ArrayList();
msgComp.add(new Integer( WMQConstants.WMQ_COMPHDR_DEFAULT));
msgComp.add(new Integer( WMQConstants.WMQ_COMPHDR_SYSTEM));
msgComp.add(new Integer( WMQConstants.WMQ_COMPHDR_NONE));
return msgComp;
}
开发者ID:dreajay,项目名称:jcode,代码行数:14,代码来源:MQUtil.java
示例7: configure
import com.ibm.msg.client.wmq.WMQConstants; //导入依赖的package包/类
/**
* Configure this class.
*
* @param props initial configuration
*
* @throws ConnectException Operation failed and connector should stop.
*/
public void configure(Map<String, String> props) {
String queueManager = props.get(MQSinkConnector.CONFIG_NAME_MQ_QUEUE_MANAGER);
String connectionNameList = props.get(MQSinkConnector.CONFIG_NAME_MQ_CONNECTION_NAME_LIST);
String channelName = props.get(MQSinkConnector.CONFIG_NAME_MQ_CHANNEL_NAME);
String queueName = props.get(MQSinkConnector.CONFIG_NAME_MQ_QUEUE);
String userName = props.get(MQSinkConnector.CONFIG_NAME_MQ_USER_NAME);
String password = props.get(MQSinkConnector.CONFIG_NAME_MQ_PASSWORD);
String builderClass = props.get(MQSinkConnector.CONFIG_NAME_MQ_MESSAGE_BUILDER);
String mbj = props.get(MQSinkConnector.CONFIG_NAME_MQ_MESSAGE_BODY_JMS);
String timeToLive = props.get(MQSinkConnector.CONFIG_NAME_MQ_TIME_TO_LIVE);
String persistent = props.get(MQSinkConnector.CONFIG_NAME_MQ_PERSISTENT);
String sslCipherSuite = props.get(MQSinkConnector.CONFIG_NAME_MQ_SSL_CIPHER_SUITE);
String sslPeerName = props.get(MQSinkConnector.CONFIG_NAME_MQ_SSL_PEER_NAME);
try {
mqConnFactory = new MQConnectionFactory();
mqConnFactory.setTransportType(WMQConstants.WMQ_CM_CLIENT);
mqConnFactory.setQueueManager(queueManager);
mqConnFactory.setConnectionNameList(connectionNameList);
mqConnFactory.setChannel(channelName);
queue = new MQQueue(queueName);
this.userName = userName;
this.password = password;
queue.setMessageBodyStyle(WMQConstants.WMQ_MESSAGE_BODY_MQ);
if (mbj != null) {
if (Boolean.parseBoolean(mbj)) {
queue.setMessageBodyStyle(WMQConstants.WMQ_MESSAGE_BODY_JMS);
}
}
if (timeToLive != null) {
this.timeToLive = Long.parseLong(timeToLive);
}
if (persistent != null) {
this.deliveryMode = Boolean.parseBoolean(persistent) ? DeliveryMode.PERSISTENT : DeliveryMode.NON_PERSISTENT;
}
if (sslCipherSuite != null) {
mqConnFactory.setSSLCipherSuite(sslCipherSuite);
if (sslPeerName != null)
{
mqConnFactory.setSSLPeerName(sslPeerName);
}
}
}
catch (JMSException | JMSRuntimeException jmse) {
log.debug("JMS exception {}", jmse);
throw new ConnectException(jmse);
}
try {
Class<? extends MessageBuilder> c = Class.forName(builderClass).asSubclass(MessageBuilder.class);
builder = c.newInstance();
}
catch (ClassNotFoundException | IllegalAccessException | InstantiationException | NullPointerException exc) {
log.debug("Could not instantiate message builder {}", builderClass);
throw new ConnectException("Could not instantiate message builder", exc);
}
}
开发者ID:ibm-messaging,项目名称:kafka-connect-mq-sink,代码行数:70,代码来源:JMSWriter.java
示例8: configure
import com.ibm.msg.client.wmq.WMQConstants; //导入依赖的package包/类
/**
* Configure this class.
*
* @param props initial configuration
*
* @throws ConnectException Operation failed and connector should stop.
*/
public void configure(Map<String, String> props) {
String queueManager = props.get(MQSourceConnector.CONFIG_NAME_MQ_QUEUE_MANAGER);
String connectionNameList = props.get(MQSourceConnector.CONFIG_NAME_MQ_CONNECTION_NAME_LIST);
String channelName = props.get(MQSourceConnector.CONFIG_NAME_MQ_CHANNEL_NAME);
String queueName = props.get(MQSourceConnector.CONFIG_NAME_MQ_QUEUE);
String userName = props.get(MQSourceConnector.CONFIG_NAME_MQ_USER_NAME);
String password = props.get(MQSourceConnector.CONFIG_NAME_MQ_PASSWORD);
String builderClass = props.get(MQSourceConnector.CONFIG_NAME_MQ_RECORD_BUILDER);
String mbj = props.get(MQSourceConnector.CONFIG_NAME_MQ_MESSAGE_BODY_JMS);
String sslCipherSuite = props.get(MQSourceConnector.CONFIG_NAME_MQ_SSL_CIPHER_SUITE);
String sslPeerName = props.get(MQSourceConnector.CONFIG_NAME_MQ_SSL_PEER_NAME);
String topic = props.get(MQSourceConnector.CONFIG_NAME_TOPIC);
try {
mqConnFactory = new MQConnectionFactory();
mqConnFactory.setTransportType(WMQConstants.WMQ_CM_CLIENT);
mqConnFactory.setQueueManager(queueManager);
mqConnFactory.setConnectionNameList(connectionNameList);
mqConnFactory.setChannel(channelName);
queue = new MQQueue(queueName);
this.userName = userName;
this.password = password;
this.messageBodyJms = false;
queue.setMessageBodyStyle(WMQConstants.WMQ_MESSAGE_BODY_MQ);
if (mbj != null) {
if (Boolean.parseBoolean(mbj)) {
this.messageBodyJms = true;
queue.setMessageBodyStyle(WMQConstants.WMQ_MESSAGE_BODY_JMS);
}
}
if (sslCipherSuite != null) {
mqConnFactory.setSSLCipherSuite(sslCipherSuite);
if (sslPeerName != null)
{
mqConnFactory.setSSLPeerName(sslPeerName);
}
}
this.topic = topic;
}
catch (JMSException | JMSRuntimeException jmse) {
log.debug("JMS exception {}", jmse);
throw new ConnectException(jmse);
}
try {
Class<? extends RecordBuilder> c = Class.forName(builderClass).asSubclass(RecordBuilder.class);
builder = c.newInstance();
}
catch (ClassNotFoundException | IllegalAccessException | InstantiationException | NullPointerException exc) {
log.debug("Could not instantiate message builder {}", builderClass);
throw new ConnectException("Could not instantiate message builder", exc);
}
}
开发者ID:ibm-messaging,项目名称:kafka-connect-mq-source,代码行数:65,代码来源:JMSReader.java
注:本文中的com.ibm.msg.client.wmq.WMQConstants类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论