當前位置: 首頁>>代碼示例>>Java>>正文


Java ObjectMessage.getObject方法代碼示例

本文整理匯總了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);
  }
}
 
開發者ID:unsftn,項目名稱:bisis-v4,代碼行數:27,代碼來源:RecordConsumer.java

示例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);
        }
    }
}
 
開發者ID:IWSDevelopers,項目名稱:iws,代碼行數:20,代碼來源:EmailSender.java

示例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");
    }
}
 
開發者ID:filipcynarski,項目名稱:EMailSenderService,代碼行數:22,代碼來源:EmailConsumer.java

示例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();
    }
}
 
開發者ID:afkham,項目名稱:msf4j-queueing,代碼行數:18,代碼來源:ReorderRequestMessageListener.java

示例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;
    }
 
開發者ID:navisidhu,項目名稱:libreacs,代碼行數:18,代碼來源:ACSServlet.java

示例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();
}
 
開發者ID:cheetah100,項目名稱:gravity,代碼行數:17,代碼來源:ClusterManagerImpl.java

示例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);
      }
   }
 
開發者ID:cacheonix,項目名稱:cacheonix-core,代碼行數:18,代碼來源:JMSSink.java

示例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);
  }
}
 
開發者ID:cscfa,項目名稱:bartleby,代碼行數:17,代碼來源:JMSQueueSink.java

示例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);
        }
    }
}
 
開發者ID:epam,項目名稱:Wilma,代碼行數:27,代碼來源:ReplicatorQueueConsumer.java

示例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);
	}
}
 
開發者ID:MSG134,項目名稱:IVCT_Framework,代碼行數:30,代碼來源:JMSLogSink.java

示例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);
	}
}
 
開發者ID:Hack23,項目名稱:cia,代碼行數:23,代碼來源:RiksdagenApiAgentWorkConsumerImpl.java

示例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);
  }
}
 
開發者ID:citerus,項目名稱:dddsample-core,代碼行數:17,代碼來源:HandlingEventRegistrationAttemptConsumer.java

示例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();
    }
}
 
開發者ID:afkham,項目名稱:msf4j-queueing,代碼行數:12,代碼來源:ReorderResponseMessageListener.java

示例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);
}
 
開發者ID:apache,項目名稱:activemq-artemis,代碼行數:29,代碼來源:JMSMessageTypesTest.java


注:本文中的javax.jms.ObjectMessage.getObject方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。