Esempio n. 1
0
 /// <summary>
 /// Default constructor
 /// </summary>
 /// <param name="localDomainService">LocalDomain</param>
 /// <param name="host">Host</param>
 /// <param name="connectorId">ServiceId</param>
 /// <param name="domainName">name of the remote Domain</param>
 /// <param name="domainEvents">Type of the remoteDomainEvents</param>
 public DomainReverse(domainServiceType localDomainService, string host, string connectorId, string domainName, Boolean createNewConnector, ABridgeExceptionHandling exceptionhandler)
     : this()
 {
     this.ExceptionHandler = exceptionhandler;
     this.Destination      = JmsDestination.CreateDestinationString(host, connectorId);
     this.connectorId      = connectorId;
     this.domainName       = domainName;
     this.domainService    = localDomainService;
     this.PortIn           = new JmsIncomingPort(Destination, exceptionhandler, connectorId);
     this.Username         = "******";
     this.Password         = "******";
     this.createService    = createNewConnector;
 }
Esempio n. 2
0
        private MethodResultMessage WaitAndCheckAnswer(JmsDestination destinationinfo, String id)
        {
            IIncomingPort       portIn = new JmsIncomingPort(JmsDestination.CreateDestinationString(destinationinfo.Host, id), ExceptionHandler, ConnectorId);
            string              reply  = portIn.Receive();
            MethodResultMessage result = Marshaller.UnmarshallObject <MethodResultMessage>(reply);

            portIn.Close();
            if (result.Result.Type == ReturnType.Exception)
            {
                throw new OpenEngSBException("Remote Exception while Registering service proxy", new Exception(result.Result.ClassName));
            }

            return(result);
        }
Esempio n. 3
0
        /// <summary>
        /// Will be invoked when a call to the proxy has been made.
        /// </summary>
        /// <param name="msg">Message, which contains the Parameters of the Method</param>
        /// <returns>Received Method</returns>
        public override IMessage Invoke(IMessage msg)
        {
            IMethodCallMessage callMessage       = msg as IMethodCallMessage;
            MethodCallMessage  methodCallRequest = ToMethodCallRequest(callMessage);
            string             methodCallMsg     = Marshaller.MarshallObject(methodCallRequest);
            IOutgoingPort      portOut           = new JmsOutgoingPort(JmsDestination.CreateDestinationString(Host, HostQueue), Exceptionhandler, ConnectorId);

            portOut.Send(methodCallMsg, methodCallRequest.CallId);
            IIncomingPort       portIn          = new JmsIncomingPort(JmsDestination.CreateDestinationString(Host, methodCallRequest.CallId), Exceptionhandler, ConnectorId);
            string              methodReturnMsg = portIn.Receive();
            MethodResultMessage methodReturn    = Marshaller.UnmarshallObject <MethodResultMessage>(methodReturnMsg);

            return(ToMessage(methodReturn.Result, callMessage));
        }
Esempio n. 4
0
        /// <summary>
        /// Blocks an waits for messages.
        /// </summary>
        public override void Listen()
        {
            try
            {
                while (IsEnabled)
                {
                    String textMsg;
                    textMsg = PortIn.Receive();

                    if (textMsg == null)
                    {
                        continue;
                    }

                    MethodCallMessage methodCallRequest = Marshaller.UnmarshallObject <MethodCallMessage>(textMsg);
                    if (methodCallRequest.MethodCall.Args == null)
                    {
                        methodCallRequest.MethodCall.Args = new List <Object>();
                    }

                    MethodResultMessage methodReturnMessage = CallMethod(methodCallRequest);
                    if (methodCallRequest.Answer)
                    {
                        string         returnMsg = Marshaller.MarshallObject(methodReturnMessage);
                        JmsDestination dest      = new JmsDestination(Destination);
                        IOutgoingPort  portOut   = new JmsOutgoingPort(JmsDestination.CreateDestinationString(dest.Host, methodCallRequest.CallId), ExceptionHandler, ConnectorId);
                        portOut.Send(returnMsg);
                        portOut.Close();
                        if (methodReturnMessage.Result.Type.Equals(ReturnType.Exception))
                        {
                            throw new BridgeException("A exception occurs, while the message has been created", new BridgeException(methodReturnMessage.Result.Arg.ToString()));
                        }
                    }
                }
            }
            catch (Exception e)
            {
                if (IsEnabled)
                {
                    ExceptionHandler.Changed += delegate(object[] obj)
                    {
                        Listen();
                        return(null);
                    };
                    ExceptionHandler.HandleException(e);
                }
            }
        }