本文整理汇总了Java中org.apache.qpid.proton.engine.Receiver.setSource方法的典型用法代码示例。如果您正苦于以下问题:Java Receiver.setSource方法的具体用法?Java Receiver.setSource怎么用?Java Receiver.setSource使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.qpid.proton.engine.Receiver
的用法示例。
在下文中一共展示了Receiver.setSource方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: newIncoming
import org.apache.qpid.proton.engine.Receiver; //导入方法依赖的package包/类
public Receiver newIncoming(Session ssn, String remote, String local) {
Receiver rcv = ssn.receiver(String.format("%s-%s", remote, local));
Source src = new Source();
src.setAddress(remote);
rcv.setSource(src);
Target tgt = new Target();
tgt.setAddress(remote);
rcv.setTarget(tgt);
return rcv;
}
示例2: createInboundLink
import org.apache.qpid.proton.engine.Receiver; //导入方法依赖的package包/类
@Override
public IncomingLink createInboundLink(String address, ReliabilityMode mode, CreditMode creditMode)
throws MessagingException {
checkClosed();
String name = UUID.randomUUID().toString();
Receiver receiver = _ssn.receiver(name);
Source source = new Source();
// Target target = new Target();
if (address == null || address.isEmpty() || address.equals("#")) {
source.setDynamic(true);
} else {
source.setAddress(address);
}
receiver.setSource(source);
// receiver.setTarget(target);
switch (mode) {
case UNRELIABLE:
receiver.setReceiverSettleMode(ReceiverSettleMode.FIRST);
receiver.setSenderSettleMode(SenderSettleMode.SETTLED);
break;
case AT_LEAST_ONCE:
receiver.setReceiverSettleMode(ReceiverSettleMode.FIRST);
receiver.setSenderSettleMode(SenderSettleMode.UNSETTLED);
break;
// case EXACTLY_ONCE:
// receiver.setReceiverSettleMode(ReceiverSettleMode.SECOND);
// receiver.setSenderSettleMode(SenderSettleMode.UNSETTLED);
// break;
}
receiver.open();
IncomingLinkImpl inLink = new IncomingLinkImpl(this, address, receiver, mode, creditMode);
inLink.setDynamicAddress(source.getDynamic());
_links.put(receiver, inLink);
receiver.setContext(inLink);
return inLink;
}
示例3: createReceiver
import org.apache.qpid.proton.engine.Receiver; //导入方法依赖的package包/类
@Override
public ProtonReceiver createReceiver(String address, ProtonLinkOptions receiverOptions) {
Receiver receiver = session.receiver(getOrCreateLinkName(receiverOptions));
Symbol[] outcomes = new Symbol[] { Accepted.DESCRIPTOR_SYMBOL, Rejected.DESCRIPTOR_SYMBOL,
Released.DESCRIPTOR_SYMBOL, Modified.DESCRIPTOR_SYMBOL };
Source source = new Source();
source.setAddress(address);
source.setOutcomes(outcomes);
source.setDefaultOutcome(Released.getInstance());
Target target = new Target();
receiver.setSource(source);
receiver.setTarget(target);
ProtonReceiverImpl r = new ProtonReceiverImpl(receiver);
r.openHandler((result) -> {
LOG.trace("Receiver open completed");
});
r.closeHandler((result) -> {
if (result.succeeded()) {
LOG.trace("Receiver closed");
} else {
LOG.warn("Receiver closed with error", result.cause());
}
});
// Default to at-least-once
r.setQoS(ProtonQoS.AT_LEAST_ONCE);
return r;
}
示例4: createInboundLink
import org.apache.qpid.proton.engine.Receiver; //导入方法依赖的package包/类
@Override
public InboundLink createInboundLink(String address, InboundLinkMode mode, CreditMode creditMode)
throws NetworkException, MessagingException
{
Receiver receiver;
Source source = new Source();
Target target = new Target();
if (address == null || address.isEmpty() || address.equals("#"))
{
String temp = UUID.randomUUID().toString();
receiver = _ssn.receiver(temp);
source.setDynamic(true);
}
else
{
receiver = _ssn.receiver(address);
source.setAddress(address);
}
receiver.setSource(source);
receiver.setTarget(target);
switch (mode)
{
case AT_MOST_ONCE:
receiver.setReceiverSettleMode(ReceiverSettleMode.FIRST);
receiver.setSenderSettleMode(SenderSettleMode.SETTLED);
break;
case AT_LEAST_ONCE:
receiver.setReceiverSettleMode(ReceiverSettleMode.FIRST);
receiver.setSenderSettleMode(SenderSettleMode.UNSETTLED);
break;
case EXACTLY_ONCE:
receiver.setReceiverSettleMode(ReceiverSettleMode.SECOND);
receiver.setSenderSettleMode(SenderSettleMode.UNSETTLED);
break;
}
receiver.open();
InboundLinkImpl inLink = new InboundLinkImpl(this, address, receiver, creditMode);
inLink.setDynamicAddress(source.getDynamic());
_links.put(receiver, inLink);
receiver.setContext(inLink);
_conn.write();
return inLink;
}
示例5: createEndpoint
import org.apache.qpid.proton.engine.Receiver; //导入方法依赖的package包/类
@Override
protected Receiver createEndpoint(JmsConsumerInfo resourceInfo) {
JmsDestination destination = resourceInfo.getDestination();
String address = AmqpDestinationHelper.INSTANCE.getDestinationAddress(destination, getParent().getConnection());
Source source = new Source();
source.setAddress(address);
Target target = new Target();
configureSource(source);
String receiverLinkName = null;
String subscriptionName = resourceInfo.getSubscriptionName();
if (subscriptionName != null && !subscriptionName.isEmpty()) {
AmqpConnection connection = getParent().getConnection();
if (resourceInfo.isShared() && !connection.getProperties().isSharedSubsSupported()) {
validateSharedSubsLinkCapability = true;
}
AmqpSubscriptionTracker subTracker = connection.getSubTracker();
// Validate subscriber type allowed given existing active subscriber types.
if (resourceInfo.isShared() && resourceInfo.isDurable()) {
if(subTracker.isActiveExclusiveDurableSub(subscriptionName)) {
// Don't allow shared sub if there is already an active exclusive durable sub
throw new JMSRuntimeException("A non-shared durable subscription is already active with name '" + subscriptionName + "'");
}
} else if (!resourceInfo.isShared() && resourceInfo.isDurable()) {
if (subTracker.isActiveExclusiveDurableSub(subscriptionName)) {
// Exclusive durable sub is already active
throw new JMSRuntimeException("A non-shared durable subscription is already active with name '" + subscriptionName + "'");
} else if (subTracker.isActiveSharedDurableSub(subscriptionName)) {
// Don't allow exclusive durable sub if there is already an active shared durable sub
throw new JMSRuntimeException("A shared durable subscription is already active with name '" + subscriptionName + "'");
}
}
// Get the link name for the subscription. Throws if certain further validations fail.
receiverLinkName = subTracker.reserveNextSubscriptionLinkName(subscriptionName, resourceInfo);
}
if(receiverLinkName == null) {
receiverLinkName = "qpid-jms:receiver:" + resourceInfo.getId() + ":" + address;
}
Receiver receiver = getParent().getEndpoint().receiver(receiverLinkName);
receiver.setSource(source);
receiver.setTarget(target);
if (resourceInfo.isBrowser() || resourceInfo.isPresettle()) {
receiver.setSenderSettleMode(SenderSettleMode.SETTLED);
} else {
receiver.setSenderSettleMode(SenderSettleMode.UNSETTLED);
}
receiver.setReceiverSettleMode(ReceiverSettleMode.FIRST);
if(validateSharedSubsLinkCapability) {
receiver.setDesiredCapabilities(new Symbol[] { AmqpSupport.SHARED_SUBS });
}
return receiver;
}