本文整理汇总了Java中javax.jms.JMSException.printStackTrace方法的典型用法代码示例。如果您正苦于以下问题:Java JMSException.printStackTrace方法的具体用法?Java JMSException.printStackTrace怎么用?Java JMSException.printStackTrace使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.jms.JMSException
的用法示例。
在下文中一共展示了JMSException.printStackTrace方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onMessage
import javax.jms.JMSException; //导入方法依赖的package包/类
/**
* Implementation of <code>MessageListener</code>.
*/
public void onMessage(Message message) {
try {
int messageCount = message.getIntProperty(JmsMessageProducer.MESSAGE_COUNT);
if (message instanceof TextMessage) {
TextMessage tm = (TextMessage)message;
String msg = tm.getText();
System.out.println("Processed message '{}'. value={}"+ msg+ messageCount);
counter.incrementAndGet();
}
} catch (JMSException e) {
e.printStackTrace();
}
}
示例2: publishControllerPendingEvents
import javax.jms.JMSException; //导入方法依赖的package包/类
private void publishControllerPendingEvents() {
isRunning = true;
lastRun = System.currentTimeMillis();
List<CMSEvent> events = controllerEventReader.getEvents();
while (events.size() > 0) {
logger.info("Got " + events.size() + " controller events; Using ControllerEventPublisher");
for (CMSEvent event : events) {
try {
if (event.getPayload() != null) {
eventPublisher.publishControllerEvents(event);
} else {
logger.info("Event payload found null for " + event.getHeaders());
}
controllerEventReader.removeEvent(event.getEventId());
} catch (JMSException e) {
e.printStackTrace();
logger.error(e.getMessage(), e);
//stopPublishing();
return;
}
}
events = controllerEventReader.getEvents();
}
//System.out.println("Done;");
}
示例3: getTtl
import javax.jms.JMSException; //导入方法依赖的package包/类
/**
* Calculate TTL of given message from message
* expiration time and message timestamp.
* <p/>
* Returns the time the message expires, which is the sum of the time-to-live value
* specified by the client and the GMT at the time of the send
* EXP_TIME = CLIENT_SEND+TTL (CLIENT_SEND??)
* CLIENT_SEND time is approximately getJMSTimestamp() (time value between send()/publish() and return)
* TODO - check for correctness
*
* @param message calculate TTL for this message
* @return positive long number if TTL was calculated. Long.MIN_VALUE if error.
*/
public static long getTtl(Message message) {
long ttl = 0;
try {
long expiration = message.getJMSExpiration();
long timestamp = message.getJMSTimestamp();
if (expiration != 0 && timestamp != 0) {
ttl = expiration - timestamp;
}
} catch (JMSException jmse) {
LOG.error("Error while calculating TTL value.\n" + jmse.getMessage());
jmse.printStackTrace();
System.exit(1);
}
return ttl;
}
示例4: testListening
import javax.jms.JMSException; //导入方法依赖的package包/类
@Test
/** test the message impl */
public void testListening() throws JMSException {
try {
listener.init();
TextMessage message = mock(TextMessage.class);
when(message.getText()).thenReturn("{messgetext:true}");
when(message.getStringProperty("task_id")).thenReturn("corel-id");
when(message.getStringProperty("task_result_code")).thenReturn(
"200");
when(message.getStringProperty("type")).thenReturn("deploybom");
when(message.getJMSCorrelationID()).thenReturn("jms|cor!rel!ation!id");
listener.onMessage(message);
listener.cleanup();
listener.getConnectionStats();
} catch (JMSException e) {
System.out.println("CAUTH EXCEPTION " + e.getMessage());
e.printStackTrace();
throw e;
}
}
示例5: onObjectMessage
import javax.jms.JMSException; //导入方法依赖的package包/类
/**
* sends an Object message instead of Text; should be ok
* it will get logged
*/
@Test
public void onObjectMessage() {
ObjectMessage objectMessage = mock(ObjectMessage.class);
NotificationMessage notificationMessage = new NotificationMessage();
notificationMessage.setTimestamp(1L);
notificationMessage.setText("mock-text");
try {
when(objectMessage.getObject()).thenReturn(notificationMessage);
} catch (JMSException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
示例6: onException
import javax.jms.JMSException; //导入方法依赖的package包/类
@Override
public void onException(Message message, Exception e) {
try {
LOG.error("Exception on message {}", message.getJMSMessageID(), e);
} catch (JMSException jmsEx) {
jmsEx.printStackTrace();
}
}
示例7: closeConnection
import javax.jms.JMSException; //导入方法依赖的package包/类
public static void closeConnection() {
if (CONNECTION_ATOMIC_REFERENCE.get() != null) {
synchronized (CONNECTION_ATOMIC_REFERENCE) {
if (CONNECTION_ATOMIC_REFERENCE.get() != null) {
try {
CONNECTION_ATOMIC_REFERENCE.get().close();
} catch (JMSException jmse) {
jmse.printStackTrace();
logger.debug(jmse.getMessage());
}
CONNECTION_ATOMIC_REFERENCE.set(null);
}
}
}
}
示例8: getLoyalty
import javax.jms.JMSException; //导入方法依赖的package包/类
@GET
@Path("/")
@Produces("application/json")
public JsonObject getLoyalty(@QueryParam("owner") String owner, @QueryParam("loyalty") String oldLoyalty, @QueryParam("total") double total) {
JsonObjectBuilder loyaltyLevel = Json.createObjectBuilder();
String loyalty = "Basic";
if (total > 1000000.00) {
loyalty = "Platinum";
} else if (total > 100000.00) {
loyalty = "Gold";
} else if (total > 50000.00) {
loyalty = "Silver";
} else if (total > 10000.00) {
loyalty = "Bronze";
}
if (!loyalty.equals(oldLoyalty)) try {
JsonObjectBuilder builder = Json.createObjectBuilder();
builder.add("owner", owner);
builder.add("old", oldLoyalty);
builder.add("new", loyalty);
JsonObject message = builder.build();
invokeJMS(message);
} catch (JMSException jms) { //in case MQ is not configured, just log the exception and continue
jms.printStackTrace();
Exception linked = jms.getLinkedException();
if (linked != null) linked.printStackTrace();
} catch (Throwable t) { //in case MQ is not configured, just log the exception and continue
t.printStackTrace();
}
loyaltyLevel.add("owner", owner);
loyaltyLevel.add("loyalty", loyalty);
return loyaltyLevel.build();
}
示例9: publishCIPendingEvents
import javax.jms.JMSException; //导入方法依赖的package包/类
private void publishCIPendingEvents() {
//logger.info("start reading" + eventType);
isRunning = true;
lastRun = System.currentTimeMillis();
List<CMSEvent> events = ciEventReader.getEvents();
while (events.size() > 0) {
logger.info("Got " + events.size() + " ci events; Using CIEventPublisher");
for (CMSEvent event : events) {
String action = event.getHeaders().get("action");
try {
if (event.getPayload() != null || "delete".equals(action)) {
eventPublisher.publishCIEvents(event);
} else {
logger.info("Event payload found null for " + event.getHeaders());
}
ciEventReader.removeEvent(event.getEventId());
} catch (JMSException e) {
e.printStackTrace();
logger.error(e.getMessage(), e);
//stopPublishing();
return;
}
}
events = ciEventReader.getEvents();
}
//System.out.println("Done;");
}
示例10: exceptionsTest
import javax.jms.JMSException; //导入方法依赖的package包/类
/**
* Exceptions test.
*
* @throws OpampException
*/
public void exceptionsTest() throws OpampException
{
OpsEventListener oel = new OpsEventListener();
opsEventListener.setGson(new Gson());
when(opsEventListener.getEventUtil().getGson()).thenReturn(new Gson());
String eventJson = makeJson(UNHEALTHY, "oldstate");
TextMessage message = mock(TextMessage.class);
try
{
when(message.getStringProperty("type")).thenReturn("ci-change-state");
when(message.getText()).thenReturn(eventJson);
}
catch (JMSException e)
{
e.printStackTrace();
}
BadStateProcessor bsProcessorMock = mock(BadStateProcessor.class);
CiChangeStateEvent changeEvent = new CiChangeStateEvent();
OpsBaseEvent event = new OpsBaseEvent();
event.setCiId(anyLong());
doThrow(new OpsException(1, "expected")).when(bsProcessorMock).processUnhealthyState(changeEvent);
oel.setBsProcessor(bsProcessorMock);
oel.onMessage(message);
// /further test coverage could be done with this mixture. save for
// later
// when(bsProcessorMock.processUnhealthyState(anyLong());
// doThrow(new
// OpampException("expected")).when(bsProcessorMock).processUnhealthyState(anyLong());
// oel.setBsProcessor(bsProcessorMock);
// bsProcessor.processUnhealthyState(event.getCiId());
}
示例11: onMessage
import javax.jms.JMSException; //导入方法依赖的package包/类
@Override
public void onMessage(Message message) {
//取消息内容
TextMessage textMessage = (TextMessage) message;
try {
String text = textMessage.getText();
log.info(text);
} catch (JMSException e) {
e.printStackTrace();
throw new XmallException("监听消息失败");
}
}
示例12: onCompletion
import javax.jms.JMSException; //导入方法依赖的package包/类
@Override
public void onCompletion(Message message) {
try {
LOG.info("Message sent {}", message.getJMSMessageID());
} catch (JMSException jmsEx) {
jmsEx.printStackTrace();
}
}
示例13: writeBinaryContentToFile
import javax.jms.JMSException; //导入方法依赖的package包/类
/**
* Write message binary body to provided file or default one in temp directory.
*
* @param filePath file to write data to
* @param message to be read and written to provided file
*/
public static void writeBinaryContentToFile(String filePath, Message message, int msgCounter) {
byte[] readByteArray;
try {
File writeBinaryFile;
if (filePath == null || filePath.equals("")) {
writeBinaryFile = File.createTempFile("recv_msg_", Long.toString(System.currentTimeMillis()));
} else {
writeBinaryFile = new File(filePath + "_" + msgCounter);
}
LOG.debug("Write binary content to file '" + writeBinaryFile.getPath() + "'.");
if (message instanceof BytesMessage) {
BytesMessage bm = (BytesMessage) message;
readByteArray = new byte[(int) bm.getBodyLength()];
bm.reset(); // added to be able to read message content
bm.readBytes(readByteArray);
try (FileOutputStream fos = new FileOutputStream(writeBinaryFile)) {
fos.write(readByteArray);
fos.close();
}
} else if (message instanceof StreamMessage) {
LOG.debug("Writing StreamMessage to");
StreamMessage sm = (StreamMessage) message;
// sm.reset(); TODO haven't tested this one
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos);
oos.writeObject(sm.readObject());
oos.close();
}
} catch (JMSException e) {
e.printStackTrace();
} catch (IOException e1) {
LOG.error("Error while writing to file '" + filePath + "'.");
e1.printStackTrace();
}
}
示例14: xmitData
import javax.jms.JMSException; //导入方法依赖的package包/类
@Override
public void xmitData(String data) {
try {
if(mXmitDisable == false){
TextMessage message = session.createTextMessage(data);
message.setStringProperty("JMSXGroupID", "Default");
message.setStringProperty("JMS_SQS_DeduplicationId", deDuplicationId+(seqNum++));
producer.send(message);
}
} catch (JMSException e) {
System.err.println( "Failed sending message: " + e.getMessage() );
e.printStackTrace();
}
}
示例15: onCompletion
import javax.jms.JMSException; //导入方法依赖的package包/类
@Override
public void onCompletion(Message request) {
try {
LOG.info("Request '{}' sent to '{}'", ((TextMessage)request).getText(), request.getJMSDestination());
} catch (JMSException jmsEx) {
jmsEx.printStackTrace();
}
}