本文整理汇总了Java中javax.jms.ObjectMessage.getObject方法的典型用法代码示例。如果您正苦于以下问题:Java ObjectMessage.getObject方法的具体用法?Java ObjectMessage.getObject怎么用?Java ObjectMessage.getObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.jms.ObjectMessage
的用法示例。
在下文中一共展示了ObjectMessage.getObject方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onMessage
import javax.jms.ObjectMessage; //导入方法依赖的package包/类
@Override
public void onMessage(Message message) {
try {
ObjectMessage objectMessage = (ObjectMessage) message;
HandlingEventRegistrationAttempt attempt
= (HandlingEventRegistrationAttempt) objectMessage.getObject();
handlingEventService.registerHandlingEvent(
attempt.getCompletionTime(),
attempt.getTrackingId(),
attempt.getVoyageNumber(),
attempt.getUnLocode(),
attempt.getType());
} catch (JMSException | CannotCreateHandlingEventException e) {
// Poison messages will be placed on dead-letter queue.
throw new RuntimeException("Error occurred processing message", e);
// } catch (JMSException e) {
// logger.log(Level.SEVERE, e.getMessage(), e);
}
}
开发者ID:RETIT,项目名称:continuous-performance-evaluation,代码行数:20,代码来源:HandlingEventRegistrationAttemptConsumer.java
示例2: onMessage
import javax.jms.ObjectMessage; //导入方法依赖的package包/类
public void onMessage(Message msg) {
try {
ObjectMessage om = (ObjectMessage)msg;
String operation = om.getStringProperty("operation");
Object obj = om.getObject();
String rashodCode = om.getStringProperty("rashodCode");
log.info("onMessage:" +operation+ "operation");
if (obj instanceof Record) {
Record rec = (Record)obj;
if ("add".equals(operation)) {
indexer.add(rec, rashodCode);
log.info("Record added, ID: " + rec.getRecordID());
} else if ("update".equals(operation)) {
indexer.update(rec, rashodCode);
log.info("Record updated, ID: " + rec.getRecordID());
}
}
else if ((obj instanceof Integer) && "delete".equals(operation)) {
Integer recID = (Integer)obj;
indexer.delete(recID);
log.info("Record deleted, ID: " + recID);
}
} catch (JMSException e) {
log.fatal(e);
}
}
示例3: onMessage
import javax.jms.ObjectMessage; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public void onMessage(final Message message) {
if (message instanceof ObjectMessage) {
final ObjectMessage msg = (ObjectMessage) message;
try {
final Serializable object = msg.getObject();
if (object instanceof EmailMessage) {
send((EmailMessage) object);
} else {
throw new IWSException(IWSErrors.ERROR, "Not a proper e-mail message.");
}
} catch (JMSException e) {
throw new IWSException(IWSErrors.ERROR, "Sending the email message failed.", e);
}
}
}
示例4: receiveMessage
import javax.jms.ObjectMessage; //导入方法依赖的package包/类
@JmsListener(destination = Queue.EMAIL_QUEUE, containerFactory = "jmsContainerFactory")
public void receiveMessage(Message message) {
if (message instanceof ObjectMessage) {
ObjectMessage objectMessage = (ObjectMessage) message;
try {
if (objectMessage.getObject() instanceof EmailJmsMessage) {
try {
EmailJmsMessage emailJmsMessage = (EmailJmsMessage) objectMessage.getObject();
emailMessage.sendEmail(emailJmsMessage.getHtml(), emailJmsMessage.getAttachments(),
emailJmsMessage.getRecipient(), emailJmsMessage.getSubject());
} catch (Exception e) {
logger.error("Email messaging exception", e);
}
}
} catch (JMSException ex) {
logger.error("JMSException thrown during Email JMS message acknowledgment:", ex);
}
} else {
logger.error("JMS: not an object message - nothing to do");
}
}
示例5: onMessage
import javax.jms.ObjectMessage; //导入方法依赖的package包/类
@Override
public void onMessage(Message message) {
ObjectMessage msg = (ObjectMessage) message;
try {
Order order = (Order) msg.getObject();
System.out.println("Got message from queue receiver==>" + order);
// Send response
OrderResponse orderResponse = new OrderResponse();
orderResponse.setItemCode(order.getItemCode());
orderResponse.setOrderQuantity(order.getQuantity());
ReorderResponseMessageSender.sendMessage(orderResponse);
} catch (JMSException | NamingException e) {
e.printStackTrace();
}
}
示例6: jmsReceiveRequest
import javax.jms.ObjectMessage; //导入方法依赖的package包/类
private Message jmsReceiveRequest(HttpSession session, Object hwid, String sn, long w) throws JMSException {
MessageConsumer consumer = (MessageConsumer) session.getAttribute("consumer");
if (consumer == null) {
// consumer = queuesession.createConsumer(queue, "OUI='" + oui + "' AND SN='" + sn + "'");
//String filter = "OUI='" + oui + "' AND SN='" + sn + "'";
String filter = "HWID='" + /*hw.getId()*/ hwid + "' AND SN='" + sn + "'";
consumer = _jms.createConsumer(filter);
session.setAttribute("consumer", consumer);
//log(lastInform, Level.FINEST, "Created consumer: " + filter);
}
ObjectMessage jm = (w == 0) ? (ObjectMessage) consumer.receiveNoWait() : (ObjectMessage) consumer.receive(w);
if (jm != null) {
return (Message) jm.getObject();
}
return null;
}
示例7: getId
import javax.jms.ObjectMessage; //导入方法依赖的package包/类
public Long getId(String path, String field) throws Exception {
if( LOG.isDebugEnabled()){
LOG.debug("Generating ID from " + path + "." + field);
}
Message message = requestId(path,field);
if(message==null){
executeChallenge();
message = requestId(path,field);
}
ObjectMessage objectMessage = (ObjectMessage) message;
IdResponse idResponse = (IdResponse) objectMessage.getObject();
return idResponse.getId();
}
示例8: onMessage
import javax.jms.ObjectMessage; //导入方法依赖的package包/类
public final void onMessage(final Message message) {
try {
if (message instanceof ObjectMessage) {
final ObjectMessage objectMessage = (ObjectMessage) message;
final LoggingEvent event = (LoggingEvent) objectMessage.getObject();
final Logger remoteLogger = Logger.getLogger(event.getLoggerName());
remoteLogger.callAppenders(event);
} else {
logger.warn("Received message is of type " + message.getJMSType()
+ ", was expecting ObjectMessage.");
}
} catch (final JMSException e) {
logger.error("Exception thrown while processing incoming message.",
e);
}
}
示例9: onMessage
import javax.jms.ObjectMessage; //导入方法依赖的package包/类
public void onMessage(javax.jms.Message message) {
ILoggingEvent event;
try {
if (message instanceof ObjectMessage) {
ObjectMessage objectMessage = (ObjectMessage) message;
event = (ILoggingEvent) objectMessage.getObject();
Logger log = (Logger) LoggerFactory.getLogger(event.getLoggerName());
log.callAppenders(event);
} else {
logger.warn("Received message is of type " + message.getJMSType()
+ ", was expecting ObjectMessage.");
}
} catch (JMSException jmse) {
logger.error("Exception thrown while processing incoming message.", jmse);
}
}
示例10: onMessage
import javax.jms.ObjectMessage; //导入方法依赖的package包/类
/**
* This method handles the replicated message (translate-send-receive-save) arrived from the queue.
*
* @param message is the message to be sent to the secondary server
*/
@Override
public void onMessage(Message message) {
if (message instanceof ObjectMessage) {
ObjectMessage objectMessage = (ObjectMessage) message;
try {
WilmaHttpRequest secondaryRequest = (WilmaHttpRequest) objectMessage.getObject();
//update the request body/headers as necessary
secondaryRequest = translateRequestToSecondaryServer(secondaryRequest);
//now send the secondary request to the secondary server, and receive response
SecondaryClient secondaryClient = new SecondaryClient();
WilmaHttpResponse secondaryResponse = secondaryClient.callSecondaryServer(secondaryRequest);
//finally store the messages
storeMessages(secondaryRequest, secondaryResponse);
} catch (JMSException e) {
logger.error("Error occurred when reading message from Replicator queue.", e);
}
}
}
示例11: onMessage
import javax.jms.ObjectMessage; //导入方法依赖的package包/类
/**
* receives messages from the JMS bus and forward them to test case logger
* if the logging events are marked with an testcase name
*/
@Override
public void onMessage(Message message) {
ILoggingEvent event;
try {
if (message.getJMSRedelivered()) {
logger.warn("ReportEngine:onMessage: MESSAGE REDELIVERED");
} else if (message instanceof ObjectMessage) {
ObjectMessage objectMessage = (ObjectMessage) message;
event = (ILoggingEvent) objectMessage.getObject();
String tc = event.getMDCPropertyMap().get("testcase");
if (tc != null) {
String sutName = event.getMDCPropertyMap().get("sutName");
String sutDir = event.getMDCPropertyMap().get("sutDir");
String badge = event.getMDCPropertyMap().get("badge");
Logger log = getTestCaseLogger(tc, sutName, sutDir, badge);
log.callAppenders(event);
}
} else {
logger.warn("Received message is of type " + message.getJMSType() + ", was expecting ObjectMessage.");
}
} catch (JMSException jmse) {
logger.error("Exception thrown while processing incoming message.", jmse);
}
}
示例12: onMessage
import javax.jms.ObjectMessage; //导入方法依赖的package包/类
@Override
public void onMessage(final Message message) {
final ObjectMessage msg = (ObjectMessage) message;
try {
LOGGER.info("Consumed message:{}", msg.getObject());
final RiksdagenDataSources dataSource = (RiksdagenDataSources) msg.getObject();
final Collection<RiksdagenDataSourcesWorkGenerator> values = beansOfType.values();
for (final RiksdagenDataSourcesWorkGenerator riksdagenDataSourcesWorkGenerator : values) {
if (riksdagenDataSourcesWorkGenerator.matches(dataSource)) {
riksdagenDataSourcesWorkGenerator.generateWorkOrders();
return;
}
}
LOGGER.warn("Missing import for :{}", dataSource);
} catch (final JMSException exception) {
LOGGER.warn("jms", exception);
}
}
示例13: onMessage
import javax.jms.ObjectMessage; //导入方法依赖的package包/类
@Override
public void onMessage(final Message message) {
try {
final ObjectMessage om = (ObjectMessage) message;
HandlingEventRegistrationAttempt attempt = (HandlingEventRegistrationAttempt) om.getObject();
handlingEventService.registerHandlingEvent(
attempt.getCompletionTime(),
attempt.getTrackingId(),
attempt.getVoyageNumber(),
attempt.getUnLocode(),
attempt.getType()
);
} catch (Exception e) {
logger.error(e, e);
}
}
示例14: onMessage
import javax.jms.ObjectMessage; //导入方法依赖的package包/类
@Override
public void onMessage(Message message) {
ObjectMessage msg = (ObjectMessage) message;
try {
OrderResponse orderResponse = (OrderResponse) msg.getObject();
System.out.println("Got message from queue receiver==>" + orderResponse);
InventoryManager.add(orderResponse.getItemCode(), orderResponse.getOrderQuantity());
} catch (JMSException e) {
e.printStackTrace();
}
}
示例15: testObjectMessageUsingCustomType
import javax.jms.ObjectMessage; //导入方法依赖的package包/类
private void testObjectMessageUsingCustomType(Connection producerConnection, Connection consumerConnection) throws Throwable {
long time = System.currentTimeMillis();
Session session = producerConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
Queue queue = session.createQueue(getQueueName());
MessageProducer producer = session.createProducer(queue);
for (int i = 0; i < NUM_MESSAGES; i++) {
System.out.println("Sending " + i);
ObjectMessage message = session.createObjectMessage(new AnythingSerializable(i));
producer.send(message);
}
Session sessionConsumer = consumerConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
Queue consumerQueue = sessionConsumer.createQueue(getQueueName());
final MessageConsumer consumer = sessionConsumer.createConsumer(consumerQueue);
for (int i = 0; i < NUM_MESSAGES; i++) {
ObjectMessage msg = (ObjectMessage) consumer.receive(5000);
Assert.assertNotNull("Could not receive message count=" + i + " on consumer", msg);
AnythingSerializable someSerialThing = (AnythingSerializable) msg.getObject();
Assert.assertEquals(i, someSerialThing.getCount());
}
long taken = (System.currentTimeMillis() - time) / 1000;
System.out.println("taken = " + taken);
}