Package jifx.commons.link

Examples of jifx.commons.link.LinkFactory


  public void commit(Context ctx) {
    logger.info("commit");
  }

  public void prepare(Context ctx) throws ParticipantException, ValidatorException {
    LinkFactory lf = LinkFactory.getFactory();
    if (properties.get("link") == null)
      throw new ParticipantException("Prepare Error: Falta configurar propiedad <link>");

    ILink lnk = lf.getLinkChannel(properties.get("link"));
    try {
      IMessage message = ctx.getOriginalMessage();
      logger.info("Send message: "+message.toString());
      IMessage msg = lnk.sendReceiveMessage(message);
      logger.info("Receive message: "+msg.toString());
View Full Code Here


  public void commit(Context ctx) {
  }

  public void prepare(Context ctx) throws ParticipantException, ValidatorException {
      try {
        LinkFactory lf = LinkFactory.getFactory();
        if (properties.get("link") == null)
          throw new ParticipantException("Prepare Error: Falta configurar propiedad <link>");
        ILink link = lf.getLinkChannel(properties.get("link"));
       
        IMessage msg = ctx.getOriginalMessage();
        String id = (String) msg.getElement("11");
        String term = (String) msg.getElement("41");
        String amount = (String) msg.getElement("4");
View Full Code Here

  public void commit(Context ctx) {
  }

  public void prepare(Context ctx) throws ParticipantException, ValidatorException {
    LinkFactory lf = LinkFactory.getFactory();
    if (properties.get("link") == null)
      throw new ParticipantException("Prepare Error: Falta configurar propiedad <link>");               
  }
View Full Code Here

  public IMessage sendReceiveMessage(IMessage message) throws ComunicationException {
    IMessage iMsg = null;
    long initialTime = System.currentTimeMillis();
    long currentTime = initialTime;
    Context jndiContext = null;
    LinkFactory linkLocate = LinkFactory.getFactory();

    try {
      linkLocate.registerLinkChannel(channelName, this);
      Hashtable<String, String> env = new Hashtable<String, String>();
//      env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.NamingContextFactory");
      env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
      env.put(Context.URL_PKG_PREFIXES, "jboss.naming:org.jnp.interfaces");
      env.put(Context.PROVIDER_URL, jndi);
      jndiContext = new InitialContext(env);

      TopicConnectionFactory connectionFactory = (TopicConnectionFactory)jndiContext.lookup("TopicConnectionFactory");           
      TopicConnection connection = connectionFactory.createTopicConnection();
      TopicSession session = connection.createTopicSession(false,Session.AUTO_ACKNOWLEDGE);     

      TopicSubscriber topicSuscriber = session.createSubscriber((Topic) jndiContext.lookup(outgoingTopic), "connection='"+channelName+"' AND owner='"+linkName+"'", false);     
      TopicPublisher topicPublisher = session.createPublisher((Topic) jndiContext.lookup(incomingTopic));
      connection.start();
     
      //Enviar a la cola de Request
      ObjectMessage objmsgReq = session.createObjectMessage(message);
      objmsgReq.setStringProperty("connection", channelName);
      objmsgReq.setStringProperty("owner", linkName);
      if (logger.isDebugEnabled())
        logger.debug(linkName+"|Link.sendReceive: "+linkName+": Enviando mensaje|"+message);
      topicPublisher.publish(objmsgReq);
     
      //Recibir desde la cola de Response
      ObjectMessage objmsgResp = null;
      while(activate && (currentTime - initialTime) < (timeout*1000)) {
        objmsgResp = (ObjectMessage)topicSuscriber.receive(1000);
        if (objmsgResp != null) {
          iMsg = (IMessage) objmsgResp.getObject();
          if (logger.isDebugEnabled())
            logger.debug(linkName+"|Link.sendReceive: "+linkName+": Recibi� mensaje|"+iMsg);
          break;
        }
        currentTime = System.currentTimeMillis();
      }
      topicPublisher.close();
      topicSuscriber.close();
      session.close();
      if (!activate) {
        logger.info(linkName+"|Link: "+linkName+": Terminado por bajada de connection|");
        throw new ComunicationException(Origin.STOP_CONNECTION);
      }
      if ((currentTime - initialTime) >= (timeout*1000)) {
        logger.info(linkName+"|Link: "+linkName+": Terminado por timeout|");
        throw new ComunicationException(Origin.TIMEOUT);
      }
    } catch (NamingException e) {
      logger.error(channelName+"|"+linkName+": "+e.getMessage()+"|");
    } catch (JMSException e) {
      logger.error(channelName+"|"+linkName+": "+e.getMessage()+"|");
    } finally {
      linkLocate.deregisterLinkChannel(channelName, this);
      if (jndiContext != null) {
        try {
          jndiContext.close();
        } catch (Exception e) {
          logger.error(linkName+"|"+linkName+": "+e.getMessage()+"|");
View Full Code Here

TOP

Related Classes of jifx.commons.link.LinkFactory

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.