当前位置: 首页>>代码示例>>Java>>正文


Java JMSException类代码示例

本文整理汇总了Java中javax.jms.JMSException的典型用法代码示例。如果您正苦于以下问题:Java JMSException类的具体用法?Java JMSException怎么用?Java JMSException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


JMSException类属于javax.jms包,在下文中一共展示了JMSException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testFailedCreateConsumerConnectionStillWorks

import javax.jms.JMSException; //导入依赖的package包/类
@Test
public void testFailedCreateConsumerConnectionStillWorks() throws JMSException {
    Connection connection = pooledConnFact.createConnection("guest", "password");
    connection.start();

    Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
    Queue queue = session.createQueue(name.getMethodName());

    try {
        session.createConsumer(queue);
        fail("Should fail to create consumer");
    } catch (JMSSecurityException ex) {
        LOG.info("Caught expected security error");
    }

    queue = session.createQueue("GUESTS." + name.getMethodName());

    MessageProducer producer = session.createProducer(queue);
    producer.close();

    connection.close();
}
 
开发者ID:messaginghub,项目名称:pooled-jms,代码行数:23,代码来源:PooledConnectionSecurityExceptionTest.java

示例2: populateMessageProperties

import javax.jms.JMSException; //导入依赖的package包/类
/**
 * Add any properties (name/value pairs) to the message as string properties
 * @param message properties will be added here
 * @param props the set of additional properties to be added to message.
 * NOTE: If values other than strings need to be added to Messages this 
 * method can be refactored to support.
 */
private void populateMessageProperties(Message message, Properties props){
    if(props == null || message == null){
        return;
    }

    Set<String> propNames = props.stringPropertyNames();
    try{
        for(String propName : propNames){
            String value = props.getProperty(propName);
            if(value != null){
                message.setStringProperty(propName, value);
            }
        }
    }catch(JMSException jmse){
        log.error("Problem added properties to Message", jmse);
    }
}
 
开发者ID:jaffa-projects,项目名称:jaffa-framework,代码行数:25,代码来源:JmsClientHelper.java

示例3: doTestCreateMessageProducer

import javax.jms.JMSException; //导入依赖的package包/类
private void doTestCreateMessageProducer(boolean useAnonymousProducers) throws JMSException {
    cf.setUseAnonymousProducers(useAnonymousProducers);

    JmsPoolConnection connection = (JmsPoolConnection) cf.createConnection();
    Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);

    Queue queue1 = session.createTemporaryQueue();
    Queue queue2 = session.createTemporaryQueue();

    JmsPoolMessageProducer producer1 = (JmsPoolMessageProducer) session.createProducer(queue1);
    JmsPoolMessageProducer producer2 = (JmsPoolMessageProducer) session.createProducer(queue2);

    if (useAnonymousProducers) {
        assertSame(producer1.getMessageProducer(), producer2.getMessageProducer());
    } else {
        assertNotSame(producer1.getMessageProducer(), producer2.getMessageProducer());
    }

    connection.close();
}
 
开发者ID:messaginghub,项目名称:pooled-jms,代码行数:21,代码来源:JmsPoolWrappedProducersTest.java

示例4: doSendBinaryMessage

import javax.jms.JMSException; //导入依赖的package包/类
private void doSendBinaryMessage( final Session session, final Destination destination,
                                  final byte[] bytes,
                                  final Map<String, ?> properties ) throws JMSException {

    try {
        BytesMessage message = session.createBytesMessage();
        message.writeBytes(bytes);
        if (properties != null) {
            // Note: Setting any properties (including JMS fields) using
            // setObjectProperty might not be supported by all providers
            // Tested with: ActiveMQ
            for (final Entry<String, ?> property : properties.entrySet()) {
                message.setObjectProperty(property.getKey(), property.getValue());
            }
        }
        final MessageProducer producer = session.createProducer(destination);
        producer.send(message);
    } finally {
        releaseSession(false);
    }
}
 
开发者ID:Axway,项目名称:ats-framework,代码行数:22,代码来源:JmsClient.java

示例5: createTopicConsumer

import javax.jms.JMSException; //导入依赖的package包/类
public MessageConsumer createTopicConsumer(String selector) throws JMSException {
	if (isQueue) {
		throw new IllegalArgumentException("Only for topic, not queue");
	}
	String consumerId = "consumer-" + UUID.randomUUID();
	topicConnection = startConnection(consumerId);
	Session session = topicConnection.createSession(isTransacted, Session.AUTO_ACKNOWLEDGE);
	Topic topic = session.createTopic(destinationName);
	if (isDurable) {
		if (selector != null) {
			return session.createDurableSubscriber(topic, consumerId, selector, true);
		} else {
			return session.createDurableSubscriber(topic, consumerId);
		}
	} else {
		if (selector != null) {
			return session.createConsumer(topic, selector);
		} else {
			return session.createConsumer(topic);
		}
	}
}
 
开发者ID:xtf-cz,项目名称:xtf,代码行数:23,代码来源:JmsClient.java

示例6: publishMessage

import javax.jms.JMSException; //导入依赖的package包/类
/**
 *
 * @throws JMSException
 */
public void publishMessage(CmsWorkOrderSimpleBase cmsWoSimpleBase, String type, String id)
    throws JMSException {
  if (isPubEnabled) {
    long t1 = System.currentTimeMillis();
    cmsWoSimpleBase = CmsUtil.maskSecuredFields(cmsWoSimpleBase, type);
    String payload = gson.toJson(cmsWoSimpleBase);
    Map<String, String> headers = new HashMap<>(2);
    headers.put("type", getType(type));
    headers.put("msgId", id);
    MessageData data = new MessageData(payload, headers);
    searchPublisher.publish(data);
    if (cmsWoSimpleBase instanceof CmsWorkOrderSimple) {
      logger.info("WO published to search stream queue for RfcId: "
          + ((CmsWorkOrderSimple) cmsWoSimpleBase).getRfcId() + " took " + (
          System.currentTimeMillis() - t1));
    } else if (cmsWoSimpleBase instanceof CmsActionOrderSimple) {
      logger.info("AO published to search stream queue for procedureId/actionId: "
          + ((CmsActionOrderSimple) cmsWoSimpleBase).getProcedureId() + "/"
          + ((CmsActionOrderSimple) cmsWoSimpleBase).getActionId() + " took " + (
          System.currentTimeMillis() - t1));
    }
  } else {
    logger.warn(">>>WOPublisher is disabled<IS_SEARCH_ENABLED>"+ isPubEnabled);
  }
}
 
开发者ID:oneops,项目名称:oneops,代码行数:30,代码来源:WoPublisher.java

示例7: createManagedConnection

import javax.jms.JMSException; //导入依赖的package包/类
private ManagedConnection createManagedConnection() {

        final ManagedConnection connection;
        final ConnectionFactory connectionFactory = getConnectionFactory();
        try {
            if (!StringUtils.isNullOrEmpty(this.username)) {
                connection = ManagedConnection.create(connectionFactory.createConnection(this.username,
                                                                                         this.password));
            } else {
                connection = ManagedConnection.create(connectionFactory.createConnection());
            }
        } catch (JMSException e) {
            throw new JmsMessageException("Error creating JMS connection from connection factory '"
                                          + defaultConnectionFactoryName + "'", e);
        }
        return connection;
    }
 
开发者ID:Axway,项目名称:ats-framework,代码行数:18,代码来源:JmsClient.java

示例8: isValidRequestResponse

import javax.jms.JMSException; //导入依赖的package包/类
/**
 * Since we use a request/response communication style with the client,
 * we must ensure that tha appropriate fields are set.
 */
private boolean isValidRequestResponse(Message incoming) {
    try {
        if (incoming.getJMSCorrelationID() == null) {
            getLogger().warn("JMSCorrelationID is not set! Will not process request");
            return false;
        }

        if (incoming.getJMSReplyTo() == null) {
            getLogger().warn("JMSReplyTo is not set! Will not process request");
            return false;
        }
    } catch (JMSException e) {
        getLogger().warn(
                "Failed to read JMSCorrelationID/JMSReplyTo. " +
                "Will not process request. Exception message = {}", e.getMessage());
        return false;
    }

    return true;
}
 
开发者ID:RWTH-i5-IDSG,项目名称:xsharing-services-router,代码行数:25,代码来源:AbstractSharingListener.java

示例9: createConsumer

import javax.jms.JMSException; //导入依赖的package包/类
@Override
public JMSConsumer createConsumer(Destination destination, String selector, boolean noLocal) {
    try {
        return startIfNeeded(new JMSConsumerImpl(this, getSession().createConsumer(destination, selector, noLocal)));
    } catch (JMSException jmse) {
        throw Utils.convertToRuntimeException(jmse);
    }
}
 
开发者ID:ops4j,项目名称:org.ops4j.pax.transx,代码行数:9,代码来源:JMSContextImpl.java

示例10: sendMessage

import javax.jms.JMSException; //导入依赖的package包/类
public void sendMessage(MessageContext messageContext,
        Destination destination, Message message) throws JMSException {
    String destinationName = destination.toString();

    if (destination instanceof Topic) {
        messageHandler.sendMessageToTopic(messageContext, destinationName,
                message);
    } else {
        messageHandler.sendMessageToQueue(messageContext, destinationName,
                message);
    }
}
 
开发者ID:zhaojunfei,项目名称:lemon,代码行数:13,代码来源:ProxyConnectionFactory.java

示例11: fail_on_get_property

import javax.jms.JMSException; //导入依赖的package包/类
@Test
public void fail_on_get_property() throws Exception {
    when(message.getPropertyNames()).thenReturn(Collections.enumeration(asList("1", "2", "3")));
    when(message.getStringProperty("1")).thenReturn("1");
    when(message.getStringProperty("2")).thenThrow(JMSException.class);
    propagator.copyFromMessage(message);
    verify(message).getStringProperty(eq("1"));
    verify(message).getStringProperty(eq("2"));
    verify(message, never()).getStringProperty(eq("3"));
    Assert.assertThat(current().containsKey("1"), is(true));
    Assert.assertThat(current().entrySet().size(), is(1));
}
 
开发者ID:enadim,项目名称:spring-cloud-ribbon-extensions,代码行数:13,代码来源:AbstractPreservesMessagePropertiesTest.java

示例12: createQueueSession

import javax.jms.JMSException; //导入依赖的package包/类
@Override
public QueueSession createQueueSession(boolean transacted, int acknowledgeMode) throws JMSException {
    checkClosedOrFailed();
    ensureConnected();
    int ackMode = getSessionAcknowledgeMode(transacted, acknowledgeMode);
    MockJMSQueueSession result = new MockJMSQueueSession(getNextSessionId(), ackMode, this);
    addSession(result);
    if (started.get()) {
        result.start();
    }
    return result;
}
 
开发者ID:messaginghub,项目名称:pooled-jms,代码行数:13,代码来源:MockJMSConnection.java

示例13: convergeIfNeeded

import javax.jms.JMSException; //导入依赖的package包/类
@Override
@Transactional
public void convergeIfNeeded(CmsActionOrderSimple ao) throws JMSException {
  long procId = ao.getProcedureId();
  long ciId = ao.getCiId();
  String logPrefix = "procedure " + procId + " ci " + ciId;
  int step = ao.getExecOrder();
  if (canConverge(ao.getProcedureId(), ao.getCiId(), step)) {
    //send a jms message to controller.workflow queue to proceed to next step
    logger.info("procedure " + procId + " ciId " + ciId + ": inductor response converging to next step");
    sendMessageToProceed(PROCEDURE.getName(), procId);
  }
  logger.info(logPrefix + " inductor response processing finished");
}
 
开发者ID:oneops,项目名称:oneops,代码行数:15,代码来源:ProcedureRunnerImpl.java

示例14: newJMSException

import javax.jms.JMSException; //导入依赖的package包/类
public static JMSException newJMSException(Throwable t) {
    if (t instanceof JMSException) {
        return (JMSException) t;
    }
    JMSException se = new JMSException(t.getMessage());
    return (JMSException) se.initCause(t);
}
 
开发者ID:ops4j,项目名称:org.ops4j.pax.transx,代码行数:8,代码来源:Utils.java

示例15: setBytes

import javax.jms.JMSException; //导入依赖的package包/类
@Override
public void setBytes(String name, byte[] value, int offset, int length) throws JMSException {
    // Fail early to avoid unnecessary array copy.
    checkKeyNameIsValid(name);

    byte[] clone = null;
    if (value != null) {
        clone = new byte[length];
        System.arraycopy(value, offset, clone, 0, length);
    }

    put(name, clone);
}
 
开发者ID:messaginghub,项目名称:pooled-jms,代码行数:14,代码来源:MockJMSMapMessage.java


注:本文中的javax.jms.JMSException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。