当前位置: 首页>>代码示例>>Java>>正文


Java MessageEndpoint类代码示例

本文整理汇总了Java中javax.resource.spi.endpoint.MessageEndpoint的典型用法代码示例。如果您正苦于以下问题:Java MessageEndpoint类的具体用法?Java MessageEndpoint怎么用?Java MessageEndpoint使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


MessageEndpoint类属于javax.resource.spi.endpoint包,在下文中一共展示了MessageEndpoint类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setup

import javax.resource.spi.endpoint.MessageEndpoint; //导入依赖的package包/类
public void setup() throws Exception {
    if (log.isTraceEnabled()) {
        log.trace("setup()");
    }
    this.consumer = new DefaultConsumer(this.channel) {
        
        @Override
        public void handleDelivery(String consumerTag, Envelope envelope,
                BasicProperties properties, byte[] body) throws IOException {
            MessageEndpoint localEndpoint;
            try {
                localEndpoint = endpointFactory.createEndpoint(null);
                RabbitmqBytesMessage m = new RabbitmqBytesMessage(consumerTag,envelope,properties,body);
                onMessage(localEndpoint, m);
            } catch (UnavailableException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
        
    };
    if ("javax.jms.Queue".equals(this.spec.getDestinationType())) {
        RabbitmqAdminQueueImpl queue = Util.lookup(new InitialContext(), this.spec.getDestination(), RabbitmqAdminQueueImpl.class);
        this.channel.basicConsume(queue.getDestinationAddress(),true, consumer);
    }
}
 
开发者ID:leogsilva,项目名称:rabbitmq-resource-adapter,代码行数:27,代码来源:RabbitmqMessageHandler.java

示例2: setup

import javax.resource.spi.endpoint.MessageEndpoint; //导入依赖的package包/类
private void setup() {
  String address = this.spec.getAddress();
  try {
    final MessageEndpoint endPoint = endpointFactory.createEndpoint(null);
    this.messageHandler = message -> handleMessage(endPoint, message);

    if (this.vertx == null) {
      throw new ResourceException("Vertx platform did not start yet.");
    }
    vertx.eventBus().consumer(address).handler(messageHandler);
    log.log(Level.INFO,
        "Endpoint created, register Vertx handler on address: " + address);
  } catch (Exception e) {
    throw new RuntimeException("Can't create the endpoint.", e);
  }
}
 
开发者ID:vert-x3,项目名称:vertx-jca,代码行数:17,代码来源:VertxActivation.java

示例3: callMdb

import javax.resource.spi.endpoint.MessageEndpoint; //导入依赖的package包/类
private String callMdb(MessageEndpoint mdb, Method command, String... params) 
                       throws ResourceException {
    String resp;
    try {
        log.info("[TrafficServiceSubscriber] callMdb()");
        mdb.beforeDelivery(command);
        Object ret = command.invoke(mdb, (Object[]) params);
        resp = (String) ret;
    } catch (NoSuchMethodException | ResourceException | 
             IllegalAccessException | IllegalArgumentException | 
             InvocationTargetException ex) {
        log.info(String.format("Invocation error %s", ex.getMessage()));
        resp = "ERROR Invocation error - " + ex.getMessage();
    }
    mdb.afterDelivery();
    return resp;
}
 
开发者ID:osmanpub,项目名称:oracle-samples,代码行数:18,代码来源:TrafficServiceSubscriber.java

示例4: invoke

import javax.resource.spi.endpoint.MessageEndpoint; //导入依赖的package包/类
private void invoke(final MessageEndpoint endpoint, final Method m, final Path path) throws WorkException {
    resourceAdapter.getBootstrapContext().getWorkManager().scheduleWork(new Work() {
        
        @Override
        public void run() {
            try {
                Method endpointMethod = endpoint.getClass().getMethod(m.getName(), m.getParameterTypes()); 
                endpoint.beforeDelivery(endpointMethod);
                
                endpointMethod.invoke(endpoint, path.toFile());
                
                endpoint.afterDelivery();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        
        @Override
        public void release() {}
    });
}
 
开发者ID:robertpanzer,项目名称:filesystemwatch-connector,代码行数:22,代码来源:FSWatchingThread.java

示例5: start

import javax.resource.spi.endpoint.MessageEndpoint; //导入依赖的package包/类
/**
 * Start the activation
 * @throws ResourceException Thrown if an error occurs
 */
public void start() throws ResourceException
{
   try
   {
      Method m = TestMessageListener.class.getMethod("onMessage", new Class<?>[] {String.class});
      
      MessageEndpoint me = endpointFactory.createEndpoint(null);
      me.beforeDelivery(m);

      TestMessageListener tml = (TestMessageListener)me;
      tml.onMessage(spec.getName());
      
      me.afterDelivery();
      me.release();
   }
   catch (ResourceException re)
   {
      throw re;
   }
   catch (Exception e)
   {
      throw new ResourceException(e);
   }
}
 
开发者ID:ironjacamar,项目名称:ironjacamar,代码行数:29,代码来源:TestActivation.java

示例6: endpointActivation

import javax.resource.spi.endpoint.MessageEndpoint; //导入依赖的package包/类
@Override
public void endpointActivation(final MessageEndpointFactory messageEndpointFactory, final ActivationSpec activationSpec) throws ResourceException {

    final Scheduler s = scheduler.get();
    if (null == s) {
        throw new ResourceException("Quartz Scheduler is not available");
    }

    try {

        final JobSpec spec = (JobSpec) activationSpec;

        final MessageEndpoint endpoint = messageEndpointFactory.createEndpoint(null);
        spec.setEndpoint(endpoint);

        final Job job = (Job) endpoint;

        final JobDataMap jobDataMap = spec.getDetail().getJobDataMap();
        jobDataMap.put(Data.class.getName(), new Data(job));

        s.scheduleJob(spec.getDetail(), spec.getTrigger());
    } catch (final SchedulerException e) {
        throw new ResourceException("Failed to schedule job", e);
    }
}
 
开发者ID:apache,项目名称:tomee,代码行数:26,代码来源:QuartzResourceAdapter.java

示例7: EndpointFactory

import javax.resource.spi.endpoint.MessageEndpoint; //导入依赖的package包/类
public EndpointFactory(final ActivationSpec activationSpec, final BaseMdbContainer container, final BeanContext beanContext, final MdbInstanceFactory instanceFactory, final MdbInstanceManager instanceManager, final XAResourceWrapper xaResourceWrapper, boolean usePool) {
    this.activationSpec = activationSpec;
    this.container = container;
    this.beanContext = beanContext;
    this.instanceFactory = instanceFactory;
    this.instanceManager = instanceManager;
    classLoader = container.getMessageListenerInterface().getClassLoader();
    interfaces = new Class[]{container.getMessageListenerInterface(), MessageEndpoint.class};
    this.xaResourceWrapper = xaResourceWrapper;
    this.usePool = usePool;
    final BeanContext.ProxyClass proxyClass = beanContext.get(BeanContext.ProxyClass.class);
    if (proxyClass == null) {
        proxy = LocalBeanProxyFactory.createProxy(beanContext.getBeanClass(), beanContext.getClassLoader(), interfaces);
        beanContext.set(BeanContext.ProxyClass.class, new BeanContext.ProxyClass(beanContext, interfaces));
    } else {
        proxy = proxyClass.getProxy();
    }
}
 
开发者ID:apache,项目名称:tomee,代码行数:19,代码来源:EndpointFactory.java

示例8: createEndpoint

import javax.resource.spi.endpoint.MessageEndpoint; //导入依赖的package包/类
@Override
public MessageEndpoint createEndpoint(final XAResource xaResource, final long timeout) throws UnavailableException {
    if (timeout <= 0) {
        return createEndpoint(xaResource);
    }

    final long end = System.currentTimeMillis() + timeout;
    MessageEndpoint messageEndpoint = null;

    while (System.currentTimeMillis() <= end) {
        try {
            messageEndpoint = createEndpoint(xaResource);
            break;
        } catch (final Exception ex) {
            // ignore so we can keep trying
        }
    }

    if (messageEndpoint != null) {
        return messageEndpoint;
    } else {
        throw new UnavailableException("Unable to create end point within the specified timeout " + timeout);
    }
}
 
开发者ID:apache,项目名称:tomee,代码行数:25,代码来源:EndpointFactory.java

示例9: createEndpoint

import javax.resource.spi.endpoint.MessageEndpoint; //导入依赖的package包/类
/**
 * The standard JCA 1.5 version of {@code createEndpoint}.
 * <p>This implementation delegates to {@link #createEndpointInternal()},
 * initializing the endpoint's XAResource before the endpoint gets invoked.
 */
@Override
public MessageEndpoint createEndpoint(XAResource xaResource) throws UnavailableException {
    AbstractMessageEndpoint endpoint = createEndpointInternal();
    endpoint.initXAResource(xaResource);
    return endpoint;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:12,代码来源:AbstractMessageEndpointFactory.java

示例10: createEndpoint

import javax.resource.spi.endpoint.MessageEndpoint; //导入依赖的package包/类
/**
 * Wrap each concrete endpoint instance with an AOP proxy,
 * exposing the message listener's interfaces as well as the
 * endpoint SPI through an AOP introduction.
 */
@Override
public MessageEndpoint createEndpoint(XAResource xaResource) throws UnavailableException {
    GenericMessageEndpoint endpoint = (GenericMessageEndpoint) super.createEndpoint(xaResource);
    ProxyFactory proxyFactory = new ProxyFactory(this.messageListener);
    DelegatingIntroductionInterceptor introduction = new DelegatingIntroductionInterceptor(endpoint);
    introduction.suppressInterface(MethodInterceptor.class);
    proxyFactory.addAdvice(introduction);
    return (MessageEndpoint) proxyFactory.getProxy();
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:15,代码来源:GenericMessageEndpointFactory.java

示例11: createEndpoint

import javax.resource.spi.endpoint.MessageEndpoint; //导入依赖的package包/类
@Override
public MessageEndpoint createEndpoint(XAResource xaResource) throws UnavailableException {
   if (xaResource != null) {
      endpoint.setXAResource(xaResource);
   }
   return endpoint;
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:8,代码来源:ActiveMQRATestBase.java

示例12: createEndpoint

import javax.resource.spi.endpoint.MessageEndpoint; //导入依赖的package包/类
@Override
public MessageEndpoint createEndpoint(XAResource xaResource) throws UnavailableException {
   TestEndpoint retEnd = new TestEndpoint();
   if (xaResource != null) {
      retEnd.setXAResource(xaResource);
   }
   return retEnd;
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:9,代码来源:MDBMultipleHandlersServerDisconnectTest.java

示例13: invoke

import javax.resource.spi.endpoint.MessageEndpoint; //导入依赖的package包/类
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {

    if (_logger.isDebugEnabled()) {
        _logger.debug(Thread.currentThread().getName() + " is invoking " + method.getName() + " on " + this);
    }
    
    acquireThreadLock();

    // beforeDelivery, afterDelivery, or release
    if (method.getDeclaringClass().equals(MessageEndpoint.class)) {
        return method.invoke(this, args);
    }

    // actual delivery
    Object ret = null;
    try {
        if (!_beforeDeliveryInvoked) {
            before(method);
        }

        ret = delivery(_delegate, method, args);
    } catch (Throwable t) {
        if (!_beforeDeliveryInvoked) {
            finish(false);
        } else {
            // The transaction will be rolled back in afterDelivery
            markTransactionAsRollbackOnly(method);
        }
        throw t;
    }
    
    if (!_beforeDeliveryInvoked) {
        finish(true);
    }
    
    return ret;
}
 
开发者ID:jboss-switchyard,项目名称:switchyard,代码行数:39,代码来源:EndpointProxy.java

示例14: createEndpoint

import javax.resource.spi.endpoint.MessageEndpoint; //导入依赖的package包/类
@Override
public MessageEndpoint createEndpoint(XAResource xaResource, long timeout)
        throws UnavailableException {
    EndpointProxy handler = new EndpointProxy(_metadata, this, xaResource);
    return (MessageEndpoint) Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(),
                                                    new Class<?>[] {_metadata.getListenerInterface(),MessageEndpoint.class},
                                                    handler);
}
 
开发者ID:jboss-switchyard,项目名称:switchyard,代码行数:9,代码来源:InboundHandler.java

示例15: handleMessage

import javax.resource.spi.endpoint.MessageEndpoint; //导入依赖的package包/类
private void handleMessage(MessageEndpoint endPoint, Message<?> message) {
  try {
    ra.getWorkManager().scheduleWork(new HandleMessage(endPoint, message));
  } catch (WorkException e) {
    throw new RuntimeException("Can't handle message.", e);
  }
}
 
开发者ID:vert-x3,项目名称:vertx-jca,代码行数:8,代码来源:VertxActivation.java


注:本文中的javax.resource.spi.endpoint.MessageEndpoint类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。