⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pooledproducer.java

📁 Jencks是一个轻量级的JCA容器。它可以轻松部署到Spring中以提供消息驱动的POJOs.此外Jencks通过使用类似于JMS,JAX-RPC,JBI与JCA CCI的API来提供对inboun
💻 JAVA
字号:
/**  * Licensed under the Apache License, Version 2.0 (the "License");  * you may not use this file except in compliance with the License.  * You may obtain a copy of the License at  *  * http://www.apache.org/licenses/LICENSE-2.0 *  * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS,  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  * See the License for the specific language governing permissions and  * limitations under the License.  *  **/package org.jencks.pool;import javax.jms.MessageProducer;import javax.jms.Destination;import javax.jms.JMSException;import javax.jms.Message;/** * A pooled {@link javax.jms.MessageProducer} * * @version $Revision$ */public class PooledProducer implements MessageProducer{  private MessageProducer messageProducer;  private Destination destination;  private int deliveryMode;  private boolean disableMessageID;  private boolean disableMessageTimestamp;  private int priority;  private long timeToLive;  public PooledProducer(final MessageProducer messageProducer,                        final Destination destination) throws JMSException  {    this.messageProducer = messageProducer;    this.destination = destination;    this.deliveryMode = messageProducer.getDeliveryMode();    this.disableMessageID = messageProducer.getDisableMessageID();    this.disableMessageTimestamp = messageProducer.getDisableMessageTimestamp();    this.priority = messageProducer.getPriority();    this.timeToLive = messageProducer.getTimeToLive();  }  public void close() throws JMSException  {  }  public void send(final Destination destination, final Message message)      throws JMSException  {    send(destination, message, getDeliveryMode(), getPriority(), getTimeToLive());  }  public void send(final Message message) throws JMSException  {    send(this.destination, message, getDeliveryMode(), getPriority(), getTimeToLive());  }  public void send(final Message message, final int deliveryMode, final int priority,                   final long timeToLive) throws JMSException  {    send(this.destination, message, deliveryMode, priority, timeToLive);  }  public void send(Destination destination, final Message message, final int deliveryMode,                   final int priority, final long timeToLive) throws JMSException  {    if (destination == null) {      destination = this.destination;    }    MessageProducer messageProducer = getMessageProducer();    // just in case let only one thread send at once    synchronized (messageProducer) {      messageProducer.send(destination, message, deliveryMode, priority, timeToLive);    }  }  public Destination getDestination()  {    return this.destination;  }  public int getDeliveryMode()  {    return this.deliveryMode;  }  public void setDeliveryMode(final int deliveryMode)  {    this.deliveryMode = deliveryMode;  }  public boolean getDisableMessageID()  {    return this.disableMessageID;  }  public void setDisableMessageID(final boolean disableMessageID)  {    this.disableMessageID = disableMessageID;  }  public boolean getDisableMessageTimestamp()  {    return this.disableMessageTimestamp;  }  public void setDisableMessageTimestamp(final boolean disableMessageTimestamp)  {    this.disableMessageTimestamp = disableMessageTimestamp;  }  public int getPriority()  {    return this.priority;  }  public void setPriority(final int priority)  {    this.priority = priority;  }  public long getTimeToLive()  {    return this.timeToLive;  }  public void setTimeToLive(final long timeToLive)  {    this.timeToLive = timeToLive;  }  // Implementation methods  //-------------------------------------------------------------------------  protected MessageProducer getMessageProducer()  {    return this.messageProducer;  }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -