mirror of https://github.com/apache/activemq.git
When the AMQP source or target address is not set, close the sender/receiver and report the error.
git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1438540 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
6473236e34
commit
37423d661c
|
@ -581,6 +581,7 @@ class AmqpProtocolConverter {
|
|||
void onReceiverOpen(final Receiver receiver, AmqpSessionContext sessionContext) {
|
||||
// Client is producing to this receiver object
|
||||
org.apache.qpid.proton.amqp.transport.Target remoteTarget = receiver.getRemoteTarget();
|
||||
try {
|
||||
if( remoteTarget instanceof Coordinator ) {
|
||||
pumpProtonToSocket();
|
||||
receiver.setContext(coordinatorContext);
|
||||
|
@ -588,12 +589,12 @@ class AmqpProtocolConverter {
|
|||
receiver.open();
|
||||
pumpProtonToSocket();
|
||||
} else {
|
||||
org.apache.qpid.proton.amqp.messaging.Target target = (Target) remoteTarget;
|
||||
Target target = (Target) remoteTarget;
|
||||
ProducerId producerId = new ProducerId(sessionContext.sessionId, sessionContext.nextProducerId++);
|
||||
ActiveMQDestination dest;
|
||||
if( target.getDynamic() ) {
|
||||
dest = createTempQueue();
|
||||
org.apache.qpid.proton.amqp.messaging.Target actualTarget = new org.apache.qpid.proton.amqp.messaging.Target();
|
||||
Target actualTarget = new Target();
|
||||
actualTarget.setAddress(dest.getQualifiedName());
|
||||
actualTarget.setDynamic(true);
|
||||
receiver.setTarget(actualTarget);
|
||||
|
@ -621,18 +622,27 @@ class AmqpProtocolConverter {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
} catch (AmqpProtocolException exception) {
|
||||
receiver.setTarget(null);
|
||||
((LinkImpl)receiver).setLocalError(new EndpointError(exception.getSymbolicName(), exception.getMessage()));
|
||||
receiver.close();
|
||||
}
|
||||
}
|
||||
|
||||
private ActiveMQDestination createDestination(Object terminus) {
|
||||
private ActiveMQDestination createDestination(Object terminus) throws AmqpProtocolException {
|
||||
if( terminus == null ) {
|
||||
return null;
|
||||
} else if( terminus instanceof org.apache.qpid.proton.amqp.messaging.Source) {
|
||||
org.apache.qpid.proton.amqp.messaging.Source source = (org.apache.qpid.proton.amqp.messaging.Source)terminus;
|
||||
if( source.getAddress() == null ) {
|
||||
throw new AmqpProtocolException("amqp:invalid-field", "source address not set");
|
||||
}
|
||||
return ActiveMQDestination.createDestination(source.getAddress(), ActiveMQDestination.QUEUE_TYPE);
|
||||
} else if( terminus instanceof org.apache.qpid.proton.amqp.messaging.Target) {
|
||||
org.apache.qpid.proton.amqp.messaging.Target target = (org.apache.qpid.proton.amqp.messaging.Target)terminus;
|
||||
if( target.getAddress() == null ) {
|
||||
throw new AmqpProtocolException("amqp:invalid-field", "target address not set");
|
||||
}
|
||||
return ActiveMQDestination.createDestination(target.getAddress(), ActiveMQDestination.QUEUE_TYPE);
|
||||
} else if( terminus instanceof Coordinator ) {
|
||||
Coordinator target = (Coordinator)terminus;
|
||||
|
@ -854,6 +864,7 @@ class AmqpProtocolConverter {
|
|||
void onSenderOpen(final Sender sender, AmqpSessionContext sessionContext) {
|
||||
org.apache.qpid.proton.amqp.messaging.Source source = (org.apache.qpid.proton.amqp.messaging.Source)sender.getRemoteSource();
|
||||
|
||||
try {
|
||||
final ConsumerId id = new ConsumerId(sessionContext.sessionId, sessionContext.nextConsumerId++);
|
||||
ConsumerContext consumerContext = new ConsumerContext(id, sender);
|
||||
sender.setContext(consumerContext);
|
||||
|
@ -963,7 +974,11 @@ class AmqpProtocolConverter {
|
|||
pumpProtonToSocket();
|
||||
}
|
||||
});
|
||||
|
||||
} catch (AmqpProtocolException e) {
|
||||
sender.setSource(null);
|
||||
((LinkImpl)sender).setLocalError(new EndpointError(e.getSymbolicName(), e.getMessage()));
|
||||
sender.close();
|
||||
}
|
||||
}
|
||||
|
||||
static private boolean contains(Symbol[] haystack, Symbol needle) {
|
||||
|
|
|
@ -23,6 +23,7 @@ public class AmqpProtocolException extends IOException {
|
|||
|
||||
private static final long serialVersionUID = -2869735532997332242L;
|
||||
|
||||
private final String symbolicName;
|
||||
private final boolean fatal;
|
||||
|
||||
public AmqpProtocolException() {
|
||||
|
@ -37,8 +38,17 @@ public class AmqpProtocolException extends IOException {
|
|||
this(s, fatal, null);
|
||||
}
|
||||
|
||||
public AmqpProtocolException(String s, String msg) {
|
||||
this(s, msg, false, null);
|
||||
}
|
||||
|
||||
public AmqpProtocolException(String s, boolean fatal, Throwable cause) {
|
||||
this("error", s, fatal, cause);
|
||||
}
|
||||
|
||||
public AmqpProtocolException(String symbolicName, String s, boolean fatal, Throwable cause) {
|
||||
super(s);
|
||||
this.symbolicName = symbolicName;
|
||||
this.fatal = fatal;
|
||||
initCause(cause);
|
||||
}
|
||||
|
@ -47,4 +57,7 @@ public class AmqpProtocolException extends IOException {
|
|||
return fatal;
|
||||
}
|
||||
|
||||
public String getSymbolicName() {
|
||||
return symbolicName;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -89,7 +89,6 @@ public abstract class ActiveMQDestination extends JNDIBaseStorable implements Da
|
|||
// static helper methods for working with destinations
|
||||
// -------------------------------------------------------------------------
|
||||
public static ActiveMQDestination createDestination(String name, byte defaultType) {
|
||||
|
||||
if (name.startsWith(QUEUE_QUALIFIED_PREFIX)) {
|
||||
return new ActiveMQQueue(name.substring(QUEUE_QUALIFIED_PREFIX.length()));
|
||||
} else if (name.startsWith(TOPIC_QUALIFIED_PREFIX)) {
|
||||
|
|
Loading…
Reference in New Issue