本文整理汇总了Java中javax.jms.DeliveryMode.PERSISTENT属性的典型用法代码示例。如果您正苦于以下问题:Java DeliveryMode.PERSISTENT属性的具体用法?Java DeliveryMode.PERSISTENT怎么用?Java DeliveryMode.PERSISTENT使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类javax.jms.DeliveryMode
的用法示例。
在下文中一共展示了DeliveryMode.PERSISTENT属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setDeliveryMode
@Override
public JMSProducer setDeliveryMode(int deliveryMode) {
switch (deliveryMode) {
case DeliveryMode.PERSISTENT:
case DeliveryMode.NON_PERSISTENT:
this.deliveryMode = deliveryMode;
return this;
default:
throw new JMSRuntimeException(String.format("Invalid DeliveryMode specified: %d", deliveryMode));
}
}
示例2: setJMSDeliveryMode
@Override
public void setJMSDeliveryMode(int deliveryMode) throws JMSException {
switch (deliveryMode) {
case DeliveryMode.PERSISTENT:
persistent = true;
break;
case DeliveryMode.NON_PERSISTENT:
persistent = false;
break;
default:
throw new JMSException(String.format("Invalid DeliveryMode specific: %d", deliveryMode));
}
}
示例3: setDeliveryMode
@Override
public void setDeliveryMode(int deliveryMode) throws JMSException {
checkClosed();
switch (deliveryMode) {
case DeliveryMode.PERSISTENT:
case DeliveryMode.NON_PERSISTENT:
this.deliveryMode = deliveryMode;
break;
default:
throw new JMSException(String.format("Invalid DeliveryMode specified: %d", deliveryMode));
}
}
示例4: getDeliveryMode
private int getDeliveryMode() {
if (persistentDelivery) {
return DeliveryMode.PERSISTENT;
}
return DeliveryMode.NON_PERSISTENT;
}
示例5: set
@Override
public void set(Message message, Object value) throws MessageFormatException {
Integer rc = (Integer) TypeConversionSupport.convert(value, Integer.class);
if (rc == null) {
Boolean bool = (Boolean) TypeConversionSupport.convert(value, Boolean.class);
if (bool == null) {
throw new MessageFormatException("Property JMSDeliveryMode cannot be set from a " + value.getClass().getName() + ".");
}
else {
rc = bool.booleanValue() ? DeliveryMode.PERSISTENT : DeliveryMode.NON_PERSISTENT;
}
}
((ActiveMQMessage) message).setJMSDeliveryMode(rc);
}
示例6: setUp
@Override
public void setUp() throws Exception {
topic = true;
durable = true;
deliveryMode = DeliveryMode.PERSISTENT;
super.setUp();
}
示例7: setUp
/**
* Set up the test with a queue and persistent delivery mode.
*
* @see junit.framework.TestCase#setUp()
*/
@Override
protected void setUp() throws Exception {
topic = false;
deliveryMode = DeliveryMode.PERSISTENT;
super.setUp();
}
示例8: testDurableQueueMessage
public void testDurableQueueMessage() throws Exception {
super.topic = false;
deliveryMode = DeliveryMode.PERSISTENT;
durableSubscriber = false;
doTest();
validateConsumerPrefetch(this.getDestinationString(), 0);
}
示例9: testDLQBrowsing
public void testDLQBrowsing() throws Exception {
super.topic = false;
deliveryMode = DeliveryMode.PERSISTENT;
durableSubscriber = false;
messageCount = 1;
connection.start();
ActiveMQConnection amqConnection = (ActiveMQConnection) connection;
rollbackCount = amqConnection.getRedeliveryPolicy().getMaximumRedeliveries() + 1;
LOG.info("Will redeliver messages: " + rollbackCount + " times");
sendMessages();
// now lets receive and rollback N times
for (int i = 0; i < rollbackCount; i++) {
makeConsumer();
Message message = consumer.receive(5000);
assertNotNull("No message received: ", message);
session.rollback();
LOG.info("Rolled back: " + rollbackCount + " times");
consumer.close();
}
makeDlqBrowser();
browseDlq();
dlqBrowser.close();
session.close();
Thread.sleep(1000);
session = connection.createSession(transactedMode, acknowledgeMode);
Queue testQueue = new ActiveMQQueue("ActiveMQ.DLQ.Queue.ActiveMQ.DLQ.Queue." + getClass().getName() + "." + getName());
MessageConsumer testConsumer = session.createConsumer(testQueue);
assertNull("The message shouldn't be sent to another DLQ", testConsumer.receive(1000));
}
示例10: setJMSDeliveryMode
@Override
public void setJMSDeliveryMode(final int deliveryMode) throws JMSException {
if (deliveryMode == DeliveryMode.PERSISTENT) {
message.setDurable(true);
} else if (deliveryMode == DeliveryMode.NON_PERSISTENT) {
message.setDurable(false);
} else {
throw ActiveMQJMSClientBundle.BUNDLE.illegalDeliveryMode(deliveryMode);
}
}
示例11: setDeliveryMode
@Override
public void setDeliveryMode(final int deliveryMode) throws JMSException {
checkClosed();
if (deliveryMode != DeliveryMode.NON_PERSISTENT && deliveryMode != DeliveryMode.PERSISTENT) {
throw ActiveMQJMSClientBundle.BUNDLE.illegalDeliveryMode(deliveryMode);
}
defaultDeliveryMode = deliveryMode;
}
示例12: getJMSDeliveryMode
@Override
public int getJMSDeliveryMode() throws JMSException {
return persistent ? DeliveryMode.PERSISTENT : DeliveryMode.NON_PERSISTENT;
}
示例13: configure
/**
* Configure this class.
*
* @param props initial configuration
*
* @throws ConnectException Operation failed and connector should stop.
*/
public void configure(Map<String, String> props) {
String queueManager = props.get(MQSinkConnector.CONFIG_NAME_MQ_QUEUE_MANAGER);
String connectionNameList = props.get(MQSinkConnector.CONFIG_NAME_MQ_CONNECTION_NAME_LIST);
String channelName = props.get(MQSinkConnector.CONFIG_NAME_MQ_CHANNEL_NAME);
String queueName = props.get(MQSinkConnector.CONFIG_NAME_MQ_QUEUE);
String userName = props.get(MQSinkConnector.CONFIG_NAME_MQ_USER_NAME);
String password = props.get(MQSinkConnector.CONFIG_NAME_MQ_PASSWORD);
String builderClass = props.get(MQSinkConnector.CONFIG_NAME_MQ_MESSAGE_BUILDER);
String mbj = props.get(MQSinkConnector.CONFIG_NAME_MQ_MESSAGE_BODY_JMS);
String timeToLive = props.get(MQSinkConnector.CONFIG_NAME_MQ_TIME_TO_LIVE);
String persistent = props.get(MQSinkConnector.CONFIG_NAME_MQ_PERSISTENT);
String sslCipherSuite = props.get(MQSinkConnector.CONFIG_NAME_MQ_SSL_CIPHER_SUITE);
String sslPeerName = props.get(MQSinkConnector.CONFIG_NAME_MQ_SSL_PEER_NAME);
try {
mqConnFactory = new MQConnectionFactory();
mqConnFactory.setTransportType(WMQConstants.WMQ_CM_CLIENT);
mqConnFactory.setQueueManager(queueManager);
mqConnFactory.setConnectionNameList(connectionNameList);
mqConnFactory.setChannel(channelName);
queue = new MQQueue(queueName);
this.userName = userName;
this.password = password;
queue.setMessageBodyStyle(WMQConstants.WMQ_MESSAGE_BODY_MQ);
if (mbj != null) {
if (Boolean.parseBoolean(mbj)) {
queue.setMessageBodyStyle(WMQConstants.WMQ_MESSAGE_BODY_JMS);
}
}
if (timeToLive != null) {
this.timeToLive = Long.parseLong(timeToLive);
}
if (persistent != null) {
this.deliveryMode = Boolean.parseBoolean(persistent) ? DeliveryMode.PERSISTENT : DeliveryMode.NON_PERSISTENT;
}
if (sslCipherSuite != null) {
mqConnFactory.setSSLCipherSuite(sslCipherSuite);
if (sslPeerName != null)
{
mqConnFactory.setSSLPeerName(sslPeerName);
}
}
}
catch (JMSException | JMSRuntimeException jmse) {
log.debug("JMS exception {}", jmse);
throw new ConnectException(jmse);
}
try {
Class<? extends MessageBuilder> c = Class.forName(builderClass).asSubclass(MessageBuilder.class);
builder = c.newInstance();
}
catch (ClassNotFoundException | IllegalAccessException | InstantiationException | NullPointerException exc) {
log.debug("Could not instantiate message builder {}", builderClass);
throw new ConnectException("Could not instantiate message builder", exc);
}
}
示例14: getMessageHeaders
/**
* Returns a String with the JMS Message Header values.
*
* @param message JMS Message
* @return String with message header values.
*/
public static String getMessageHeaders(Message message) {
final StringBuilder response = new StringBuilder(256);
try {
response.append("JMS Message Header Attributes:");
response.append("\n Correlation ID: ");
response.append(message.getJMSCorrelationID());
response.append("\n Delivery Mode: ");
if (message.getJMSDeliveryMode() == DeliveryMode.PERSISTENT) {
response.append("PERSISTANT");
} else {
response.append("NON-PERSISTANT");
}
final Destination destination = message.getJMSDestination();
response.append("\n Destination: ");
response.append((destination == null ? null : destination
.toString()));
response.append("\n Expiration: ");
response.append(new Date(message.getJMSExpiration()));
response.append("\n Message ID: ");
response.append(message.getJMSMessageID());
response.append("\n Priority: ");
response.append(message.getJMSPriority());
response.append("\n Redelivered: ");
response.append(message.getJMSRedelivered());
final Destination replyTo = message.getJMSReplyTo();
response.append("\n Reply to: ");
response.append((replyTo == null ? null : replyTo.toString()));
response.append("\n Timestamp: ");
response.append(new Date(message.getJMSTimestamp()));
response.append("\n Type: ");
response.append(message.getJMSType());
response.append("\n\n");
} catch (JMSException e) {
e.printStackTrace();
}
return new String(response);
}
示例15: sample
/**
* {@inheritDoc}
*/
@Override
public SampleResult sample(Entry entry) {
SampleResult res = new SampleResult();
res.setSampleLabel(getName());
res.setSamplerData(getContent());
res.setSuccessful(false); // Assume failure
res.setDataType(SampleResult.TEXT);
res.sampleStart();
try {
TextMessage msg = createMessage();
if (isOneway()) {
int deliveryMode = isNonPersistent() ?
DeliveryMode.NON_PERSISTENT:DeliveryMode.PERSISTENT;
producer.send(msg, deliveryMode, Integer.parseInt(getPriority()),
Long.parseLong(getExpiration()));
res.setRequestHeaders(Utils.messageProperties(msg));
res.setResponseOK();
res.setResponseData("Oneway request has no response data", null);
} else {
if (!useTemporyQueue()) {
msg.setJMSReplyTo(receiveQueue);
}
Message replyMsg = executor.sendAndReceive(msg,
isNonPersistent() ? DeliveryMode.NON_PERSISTENT : DeliveryMode.PERSISTENT,
Integer.parseInt(getPriority()),
Long.parseLong(getExpiration()));
res.setRequestHeaders(Utils.messageProperties(msg));
if (replyMsg == null) {
res.setResponseMessage("No reply message received");
} else {
if (replyMsg instanceof TextMessage) {
res.setResponseData(((TextMessage) replyMsg).getText(), null);
} else {
res.setResponseData(replyMsg.toString(), null);
}
res.setResponseHeaders(Utils.messageProperties(replyMsg));
res.setResponseOK();
}
}
} catch (Exception e) {
log.warn(e.getLocalizedMessage(), e);
if (thrown != null){
res.setResponseMessage(thrown.toString());
} else {
res.setResponseMessage(e.getLocalizedMessage());
}
}
res.sampleEnd();
return res;
}