本文整理了Java中org.apache.qpid.proton.engine.Event
类的一些代码示例,展示了Event
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Event
类的具体详情如下:
包路径:org.apache.qpid.proton.engine.Event
类名称:Event
[英]Event
[中]事件
代码示例来源:origin: com.microsoft.azure.iot/proton-j-azure-iot
private Handler eventHandler(Event event) {
Handler result;
if (event.getLink() != null) {
result = BaseHandler.getHandler(event.getLink());
if (result != null) return result;
}
if (event.getSession() != null) {
result = BaseHandler.getHandler(event.getSession());
if (result != null) return result;
}
if (event.getConnection() != null) {
result = BaseHandler.getHandler(event.getConnection());
if (result != null) return result;
}
if (event.getTask() != null) {
result = BaseHandler.getHandler(event.getTask());
if (result != null) return result;
}
if (event.getSelectable() != null) {
result = BaseHandler.getHandler(event.getSelectable());
if (result != null) return result;
}
return handler;
}
代码示例来源:origin: org.apache.qpid/proton-j
@Override
public void onUnhandled(Event event) {
int window = this.window;
Link link = event.getLink();
switch(event.getType()) {
case LINK_LOCAL_OPEN:
case LINK_REMOTE_OPEN:
case LINK_FLOW:
case DELIVERY:
if (link instanceof Receiver) {
this.drained += link.drained();
if (this.drained == 0) {
topup((Receiver)link, window);
}
}
break;
default:
break;
}
}
}
代码示例来源:origin: Azure/azure-event-hubs-java
@Override
public void onTransportClosed(Event event) {
final Transport transport = event.getTransport();
final Connection connection = event.getConnection();
if (TRACE_LOGGER.isInfoEnabled()) {
TRACE_LOGGER.info(String.format(Locale.US, "onTransportClosed hostname[%s]",
(connection != null ? connection.getHostname() : "n/a")));
}
if (transport != null && connection != null && connection.getTransport() != null) {
transport.unbind();
}
}
}
代码示例来源:origin: stackoverflow.com
Map<Map<Integer, Venue>,String> uniqueMap = new HashMap<>();
for (Event event: events) { // assuming events is ArrayList
Map<Integer, Venue> sessionVenueMap = new HashMap<>();
sessionVenueMap.put(event.getSession(), event.getVenue());
//check if we stored this pair in our cool map
if (uniqueMap.get(sessionVenueMap) == null) {
//if not
//store this in our uniqieMap in our method
uniqueMap.put(sessionVenueMap, event.getAct);
sessionVenueMap.put(event.getSession(), event.getVenue);
} else {
// if map has this pair
// then it is not unique
return false;
}
venueSessionMap.put(.getVenue(); event.getSession();
}
return true;
代码示例来源:origin: apache/activemq-artemis
public static void dispatch(Event event, EventHandler handler) throws Exception {
switch (event.getType()) {
case CONNECTION_INIT:
handler.onInit(event.getConnection());
break;
case CONNECTION_LOCAL_OPEN:
handler.onLocalOpen(event.getConnection());
break;
case CONNECTION_REMOTE_OPEN:
handler.onRemoteOpen(event.getConnection());
break;
case CONNECTION_LOCAL_CLOSE:
handler.onLocalClose(event.getConnection());
break;
case CONNECTION_REMOTE_CLOSE:
handler.onRemoteClose(event.getConnection());
break;
case CONNECTION_FINAL:
handler.onFinal(event.getConnection());
break;
case SESSION_INIT:
handler.onInit(event.getSession());
break;
case SESSION_LOCAL_OPEN:
handler.onLocalOpen(event.getSession());
break;
case SESSION_REMOTE_OPEN:
handler.onRemoteOpen(event.getSession());
break;
case SESSION_LOCAL_CLOSE:
代码示例来源:origin: apache/activemq-artemis
Event protonEvent = null;
while ((protonEvent = protonCollector.peek()) != null) {
if (!protonEvent.getType().equals(Type.TRANSPORT)) {
LOG.trace("Client: New Proton Event: {}", protonEvent.getType());
switch (protonEvent.getType()) {
case CONNECTION_REMOTE_CLOSE:
amqpEventSink = (AmqpEventSink) protonEvent.getConnection().getContext();
amqpEventSink.processRemoteClose(this);
break;
case CONNECTION_REMOTE_OPEN:
amqpEventSink = (AmqpEventSink) protonEvent.getConnection().getContext();
amqpEventSink.processRemoteOpen(this);
break;
case SESSION_REMOTE_CLOSE:
amqpEventSink = (AmqpEventSink) protonEvent.getSession().getContext();
amqpEventSink.processRemoteClose(this);
break;
case SESSION_REMOTE_OPEN:
amqpEventSink = (AmqpEventSink) protonEvent.getSession().getContext();
amqpEventSink.processRemoteOpen(this);
break;
case LINK_REMOTE_CLOSE:
amqpEventSink = (AmqpEventSink) protonEvent.getLink().getContext();
amqpEventSink.processRemoteClose(this);
break;
case LINK_REMOTE_DETACH:
amqpEventSink = (AmqpEventSink) protonEvent.getLink().getContext();
amqpEventSink.processRemoteDetach(this);
代码示例来源:origin: Azure/azure-iot-sdk-java
/**
* Event handler for the delivery event. This method handles both sending and receiving a message.
* @param event The Proton Event object.
*/
@Override
public void onDelivery(Event event)
{
logger.LogDebug("Entered in method %s", logger.getMethodName());
AmqpMessage message = amqpDeviceOperations.receiverMessageFromLink(event.getLink().getName());
if (message == null)
{
//Sender specific section for dispositions it receives
if (event.getType() == Event.Type.DELIVERY)
{
// Codes_SRS_AMQPSIOTHUBCONNECTION_15_038: [If this link is the Sender link and the event type is DELIVERY, the event handler shall get the Delivery (Proton) object from the event.]
Delivery d = event.getDelivery();
DeliveryState remoteState = d.getRemoteState();
// Codes_SRS_AMQPSIOTHUBCONNECTION_15_039: [The event handler shall note the remote delivery state and use it and the Delivery (Proton) hash code to inform the AmqpsIotHubConnection of the message receipt.]
boolean state = remoteState.equals(Accepted.getInstance());
//let any listener know that the message was received by the server
// release the delivery object which created in sendMessage().
d.free();
}
}
else
{
msgListener.messageReceived(message);
}
logger.LogDebug("Exited from method %s", logger.getMethodName());
}
代码示例来源:origin: com.ibm.mqlight/mqlight-api
private void processEventSessionRemoteState(Event event) {
final String methodName = "processEventSessionRemoteState";
logger.entry(this, methodName, event);
if (event.getSession().getRemoteState() == EndpointState.ACTIVE) {
if (event.getSession().getLocalState() == EndpointState.ACTIVE) {
final EngineConnection engineConnection =
(EngineConnection) event.getConnection().getContext();
if (!engineConnection.closed) {
// First session has opened on the connection
OpenRequest req = engineConnection.openRequest;
engineConnection.openRequest = null;
engineConnection.requestor.tell(new OpenResponse(req, engineConnection), this);
}
} else {
// The remote end is trying to establish a new session with us, which is not allowed. I don't think this is a usual case,
// but could occur with a badly written remote end (i.e. sends an initial AMQP open immediately followed by a begin)
final Connection protonConnection = event.getConnection();
protonConnection.setCondition(new ErrorCondition(Symbol.getSymbol("mqlight:session-remote-open-rejected"),
"MQ Light client is unable to accept an open session request"));
protonConnection.close();
}
}
logger.exit(this, methodName);
}
代码示例来源:origin: Azure/azure-event-hubs-java
@Override
public void onConnectionUnbound(Event event) {
final Connection connection = event.getConnection();
if (TRACE_LOGGER.isInfoEnabled()) {
TRACE_LOGGER.info(String.format(Locale.US, "onConnectionUnbound: hostname[%s], state[%s], remoteState[%s]",
connection.getHostname(), connection.getLocalState(), connection.getRemoteState()));
}
// if failure happened while establishing transport - nothing to free up.
if (connection.getRemoteState() != EndpointState.UNINITIALIZED)
connection.free();
}
代码示例来源:origin: org.apache.qpid/proton-j
@Override
public void onLinkRemoteClose(Event event) {
close(event.getLink());
}
}
代码示例来源:origin: Azure/azure-service-bus-java
@Override
public void onConnectionLocalClose(Event event) {
Connection connection = event.getConnection();
TRACE_LOGGER.debug("onConnectionLocalClose: hostname:{}", connection.getHostname());
if(connection.getRemoteState() == EndpointState.CLOSED)
{
// Service closed it first. In some such cases transport is not unbound and causing a leak.
if(connection.getTransport() != null)
{
connection.getTransport().unbind();
}
connection.free();
}
}
}
代码示例来源:origin: Azure/azure-event-hubs-java
@Override
public void onConnectionLocalClose(Event event) {
final Connection connection = event.getConnection();
final ErrorCondition error = connection.getCondition();
if (TRACE_LOGGER.isInfoEnabled()) {
TRACE_LOGGER.info(String.format(Locale.US, "onConnectionLocalClose: hostname[%s], errorCondition[%s], errorDescription[%s]",
connection.getHostname(),
error != null ? error.getCondition() : "n/a",
error != null ? error.getDescription() : "n/a"));
}
if (connection.getRemoteState() == EndpointState.CLOSED) {
// This means that the CLOSE origin is Service
final Transport transport = connection.getTransport();
if (transport != null) {
transport.unbind(); // we proactively dispose IO even if service fails to close
}
}
}
代码示例来源:origin: Azure/azure-service-bus-java
@Override
public void onConnectionRemoteClose(Event event)
{
final Connection connection = event.getConnection();
final ErrorCondition error = connection.getRemoteCondition();
TRACE_LOGGER.debug("onConnectionRemoteClose: hostname:{},errorCondition:{}", connection.getHostname(), error != null ? error.getCondition() + "," + error.getDescription() : null);
boolean shouldFreeConnection = connection.getLocalState() == EndpointState.CLOSED;
this.messagingFactory.onConnectionError(error);
if(shouldFreeConnection)
{
connection.free();
}
}
代码示例来源:origin: com.ibm.mqlight/mqlight-api
logger.entry(this, methodName, event);
EngineConnection engineConnection = (EngineConnection)event.getConnection().getContext();
Delivery delivery = event.getDelivery();
if (event.getLink() instanceof Sender) {
SendRequest sr = engineConnection.inProgressOutboundDeliveries.remove(delivery);
Exception exception = null;
event.getLink().close();
event.getLink().free();
Receiver receiver = (Receiver)event.getLink();
int amount = delivery.pending();
byte[] data = new byte[amount];
receiver.advance();
EngineConnection.SubscriptionData subData = engineConnection.subscriptionData.get(event.getLink().getName());
subData.unsettled++;
QOS qos = delivery.remotelySettled() ? QOS.AT_MOST_ONCE : QOS.AT_LEAST_ONCE;
subData.subscriber.tell(new DeliveryRequest(data, qos, event.getLink().getName(), delivery, event.getConnection()), this);
代码示例来源:origin: Azure/azure-event-hubs-java
@Override
public void onTransportClosed(Event event) {
final Connection connection = event.getConnection();
final Transport transport = event.getTransport();
final ErrorCondition condition = transport.getCondition();
if (TRACE_LOGGER.isInfoEnabled()) {
TRACE_LOGGER.info(String.format(Locale.US, "onTransportClosed: hostname[%s], error[%s]",
connection != null ? connection.getHostname() : "n/a", (condition != null ? condition.getDescription() : "n/a")));
}
if (connection != null && connection.getRemoteState() != EndpointState.CLOSED) {
// if the remote-peer abruptly closes the connection without issuing close frame
// issue one
this.amqpConnection.onConnectionError(condition);
}
}
代码示例来源:origin: Azure/azure-iot-sdk-java
@Override
public void onDelivery(Event event)
{
//Codes_SRS_SERVICE_SDK_JAVA_AMQPSENDHANDLER_25_023: [ The event handler shall get the Delivery from the event only if the event type is DELIVERY **]**
if(event.getType() == Event.Type.DELIVERY)
{
// Codes_SRS_AMQPSIOTHUBCONNECTION_15_038: [If this link is the Sender link and the event type is DELIVERY, the event handler shall get the Delivery (Proton) object from the event.]
Delivery d = event.getDelivery();
//Codes_SRS_SERVICE_SDK_JAVA_AMQPSENDHANDLER_25_024: [ The event handler shall get the Delivery remote state from the delivery **]**
DeliveryState remoteState = d.getRemoteState();
//Codes_SRS_SERVICE_SDK_JAVA_AMQPSENDHANDLER_25_025: [ The event handler shall verify the Amqp response and add the response to a queue. **]**
sendStatusQueue.add(new AmqpResponseVerification(remoteState));
//Codes_SRS_SERVICE_SDK_JAVA_AMQPSENDHANDLER_25_026: [ The event handler shall settle the delivery. **]**
d.settle();
//Codes_SRS_SERVICE_SDK_JAVA_AMQPSENDHANDLER_25_027: [ The event handler shall get the Sender (Proton) object from the event **]**
Sender snd = event.getSender();
//Codes_SRS_SERVICE_SDK_JAVA_AMQPSENDHANDLER_25_028: [ The event handler shall close the Sender, Session and Connection **]**
snd.close();
snd.getSession().close();
snd.getSession().getConnection().close();
isConnected = false;
}
}
代码示例来源:origin: org.apache.qpid/proton-j
@Override
public void onUnhandled(Event event) {
try {
ReactorImpl reactor = (ReactorImpl)event.getReactor();
Selector selector = reactor.getSelector();
if (selector == null) {
switch(event.getType()) {
case SELECTABLE_INIT:
selectable = event.getSelectable();
selector.add(selectable);
break;
case SELECTABLE_UPDATED:
selectable = event.getSelectable();
selector.update(selectable);
break;
case SELECTABLE_FINAL:
selectable = event.getSelectable();
selector.remove(selectable);
selectable.release();
break;
case TRANSPORT_CLOSED:
event.getTransport().unbind();
break;
case REACTOR_QUIESCED:
代码示例来源:origin: Azure/azure-event-hubs-java
@Override
protected void notifyTransportErrors(final Event event) {
final Transport transport = event.getTransport();
final Connection connection = event.getConnection();
if (connection == null || transport == null) {
return;
final String hostName = event.getReactor().getConnectionAddress(connection);
final ProxySelector proxySelector = ProxySelector.getDefault();
代码示例来源:origin: com.microsoft.azure.iot/proton-j-azure-iot
@Override
public void onSessionRemoteOpen(Event event) {
open(event.getSession());
}
代码示例来源:origin: Azure/azure-service-bus-java
@Override
public void onConnectionRemoteOpen(Event event)
{
TRACE_LOGGER.debug("Connection.onConnectionRemoteOpen: hostname:{}, remotecontainer:{}", event.getConnection().getHostname(), event.getConnection().getRemoteContainer());
this.messagingFactory.onConnectionOpen();
}
内容来源于网络,如有侵权,请联系作者删除!