本文整理汇总了Java中javax.jms.ObjectMessage.setObject方法的典型用法代码示例。如果您正苦于以下问题:Java ObjectMessage.setObject方法的具体用法?Java ObjectMessage.setObject怎么用?Java ObjectMessage.setObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.jms.ObjectMessage
的用法示例。
在下文中一共展示了ObjectMessage.setObject方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: sendObjectMsgSingleSession
import javax.jms.ObjectMessage; //导入方法依赖的package包/类
private void sendObjectMsgSingleSession(List<? extends Serializable> objectsToSend) throws JMSException {
Session session = null;
Connection conn = null;
try {
conn = qFactory.createConnection();
session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
MessageProducer producer = session.createProducer(queue);
for (Serializable objectToSend : objectsToSend) {
ObjectMessage msg = session.createObjectMessage();
msg.setObject(objectToSend);
producer.send(msg);
}
} finally {
closeSession(session);
closeConnection(conn);
}
}
示例2: send
import javax.jms.ObjectMessage; //导入方法依赖的package包/类
/**
* Sends a message to the myWMS application inside the application
* server.
*
* @param mfcMessage the message to be send
* @throws JMSException
* @throws NamingException
*/
public void send(MFCMessage mfcMessage)
throws JMSException,
NamingException
{
// create the jms session
QueueSession session =
connection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
// lookup of the jms queue over jndi
Queue outputQueue =
(Queue) context.lookup("queue/" + OUTPUT_QUEUE_NAME);
// create the message publisher
QueueSender sender = session.createSender(outputQueue);
ObjectMessage objectMessage = session.createObjectMessage();
objectMessage.setObject(mfcMessage);
objectMessage.setJMSTimestamp(System.currentTimeMillis());
sender.send(objectMessage);
sender.close();
session.close();
}
示例3: append
import javax.jms.ObjectMessage; //导入方法依赖的package包/类
/**
This method called by {@link AppenderSkeleton#doAppend} method to
do most of the real appending work. */
public void append(LoggingEvent event) {
if(!checkEntryConditions()) {
return;
}
try {
ObjectMessage msg = topicSession.createObjectMessage();
if(locationInfo) {
event.getLocationInformation();
}
msg.setObject(event);
topicPublisher.publish(msg);
} catch(Exception e) {
errorHandler.error("Could not publish message in JMSAppender ["+name+"].", e,
ErrorCode.GENERIC_FAILURE);
}
}
示例4: append
import javax.jms.ObjectMessage; //导入方法依赖的package包/类
/**
* This method called by {@link AppenderSkeleton#doAppend} method to do most of the real appending work.
*/
public void append(final LoggingEvent event) {
if (!checkEntryConditions()) {
return;
}
try {
final ObjectMessage msg = topicSession.createObjectMessage();
if (locationInfo) {
event.getLocationInformation();
}
msg.setObject(event);
topicPublisher.publish(msg);
} catch (final Exception e) {
errorHandler.error("Could not publish message in JMSAppender [" + name + "].", e,
ErrorCode.GENERIC_FAILURE);
}
}
示例5: append
import javax.jms.ObjectMessage; //导入方法依赖的package包/类
/**
* This method called by {@link AppenderBase#doAppend} method to do most
* of the real appending work.
*/
public void append(ILoggingEvent event) {
if (!isStarted()) {
return;
}
try {
ObjectMessage msg = queueSession.createObjectMessage();
Serializable so = pst.transform(event);
msg.setObject(so);
queueSender.send(msg);
successiveFailureCount = 0;
} catch (Exception e) {
successiveFailureCount++;
if (successiveFailureCount > SUCCESSIVE_FAILURE_LIMIT) {
stop();
}
addError("Could not send message in JMSQueueAppender [" + name + "].", e);
}
}
示例6: publish
import javax.jms.ObjectMessage; //导入方法依赖的package包/类
public static void publish(String dest, Serializable object, String contentType, String tag) throws Exception {
Connection conn = connectionFactory.createConnection();
try {
Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
Destination destination = createDestination(dest);
MessageProducer producer = session.createProducer(destination);
ObjectMessage message = session.createObjectMessage();
if (contentType != null) {
message.setStringProperty(HttpHeaderProperty.CONTENT_TYPE, contentType);
}
if (tag != null) {
message.setStringProperty("MyTag", tag);
}
message.setObject(object);
producer.send(message);
} finally {
conn.close();
}
}
示例7: jmsSendMessage
import javax.jms.ObjectMessage; //导入方法依赖的package包/类
private void jmsSendMessage(Serializable value, String destName, boolean isQueue) throws JMSException {
ConnectionFactory factory = new ActiveMQJMSConnectionFactory("tcp://localhost:61616");
String jmsDest;
if (isQueue) {
jmsDest = QUEUE_QUALIFIED_PREFIX + destName;
} else {
jmsDest = TOPIC_QUALIFIED_PREFIX + destName;
}
Destination destination = ActiveMQDestination.fromPrefixedName(jmsDest);
Connection conn = factory.createConnection();
try {
Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
MessageProducer producer = session.createProducer(destination);
ObjectMessage message = session.createObjectMessage();
message.setStringProperty(HttpHeaderProperty.CONTENT_TYPE, "application/xml");
message.setObject(value);
producer.send(message);
} finally {
conn.close();
}
}
示例8: send
import javax.jms.ObjectMessage; //导入方法依赖的package包/类
@Override
public JMSProducer send(Destination destination, Serializable body) {
try {
ObjectMessage message = session.createObjectMessage();
message.setObject(body);
doSend(destination, message);
} catch (JMSException jmse) {
throw JMSExceptionSupport.createRuntimeException(jmse);
}
return this;
}
示例9: send
import javax.jms.ObjectMessage; //导入方法依赖的package包/类
@Override
public JMSProducer send(Destination destination, Serializable body) {
try {
ObjectMessage message = context.createObjectMessage();
message.setObject(body);
doSend(destination, message);
} catch (JMSException jmse) {
throw Utils.convertToRuntimeException(jmse);
}
return this;
}
示例10: sendMessage
import javax.jms.ObjectMessage; //导入方法依赖的package包/类
private void sendMessage(String command, Serializable obj, String rashodCode) throws JMSException {
ObjectMessage addMessage = session.createObjectMessage();
addMessage.setStringProperty("operation", command);
addMessage.setStringProperty("rashodCode", rashodCode);
addMessage.setObject(obj);
producer.send(addMessage);
}
示例11: sendMessage
import javax.jms.ObjectMessage; //导入方法依赖的package包/类
public void sendMessage(ConnectionFactory connectionFactory, Queue queue, Serializable messageData) throws JMSException {
Connection connection = connectionFactory.createConnection();
Session session = connection.createSession(
false,
Session.AUTO_ACKNOWLEDGE);
MessageProducer producer = session.createProducer(queue);
ObjectMessage objectMessage = session.createObjectMessage();
objectMessage.setObject(messageData);
producer.send(objectMessage);
}
示例12: sendResponseMessage
import javax.jms.ObjectMessage; //导入方法依赖的package包/类
public void sendResponseMessage(Serializable object, String id) throws JMSException {
ObjectMessage message = queuesession.createObjectMessage();
message.setObject(object);
if (id != null) {
message.setJMSCorrelationID(id);
}
message.setJMSExpiration(3600 * 1000);
producer.send(queue, message);
}
示例13: sendCallMessage
import javax.jms.ObjectMessage; //导入方法依赖的package包/类
public void sendCallMessage(Serializable object, String id, HostsLocal host/*String oui, String sn*/) throws JMSException {
ObjectMessage msg = queuesession.createObjectMessage();
msg.setJMSMessageID(id);
msg.setJMSExpiration(3600 * 1000);
msg.setObject(object);
/*
msg.setStringProperty("OUI", oui);
msg.setStringProperty("SN", sn);
*/
msg.setStringProperty("HWID", host.getHwid().toString());
msg.setStringProperty("SN", host.getSerialno());
producer.send(queue, msg);
}
示例14: putBackMessageOnIndexerQueue
import javax.jms.ObjectMessage; //导入方法依赖的package包/类
private boolean putBackMessageOnIndexerQueue(Message message) {
if (message instanceof ObjectMessage) {
Session session = null;
Connection conn = null;
try {
Context jndiContext = getContext();
ConnectionFactory qFactory = (ConnectionFactory) jndiContext
.lookup("jms/bss/indexerQueueFactory");
conn = qFactory.createConnection();
Queue queue = (Queue) jndiContext
.lookup("jms/bss/indexerQueue");
session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
MessageProducer producer = session.createProducer(queue);
ObjectMessage msg = session.createObjectMessage();
msg.setObject(((ObjectMessage) message).getObject());
producer.send(msg);
return true;
} catch (Throwable e) {
// This should not happen because the indexer queue is in the
// local server. If it happens, than there's something terribly
// wrong.
throw new SaaSSystemException(e);
} finally {
closeSession(session);
closeConnection(conn);
}
} else {
return false;
}
}
示例15: sendCompressedObjectMessageUsingOpenWire
import javax.jms.ObjectMessage; //导入方法依赖的package包/类
private void sendCompressedObjectMessageUsingOpenWire() throws Exception {
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
ActiveMQDestination destination = createDestination(session, ActiveMQDestination.QUEUE_TYPE);
final ActiveMQMessageProducer producer = (ActiveMQMessageProducer) session.createProducer(destination);
ObjectMessage objectMessage = session.createObjectMessage();
objectMessage.setObject(TEXT);
producer.send(objectMessage);
}