Author Topic: Using existing channel with Interaction Server  (Read 2567 times)

Offline anninkov

  • Newbie
  • *
  • Posts: 1
  • Karma: 0
Using existing channel with Interaction Server
« on: January 21, 2016, 11:21:36 AM »
In my custom extension to Workspace Desktop Edition I want to open a connection to Interaction Server and create a new interaction with attached data.
Genesys recommend to do it in this way:

-----------------------------------------------------------------------------------------------------------
InteractionServerProtocol interactionServerProtocol = new InteractionServerProtocol(
                    new Endpoint("InteractionServer", host, port));

            interactionServerProtocol.ClientName = "EntityListener";
            interactionServerProtocol.ClientType = InteractionClient.MediaServer;

            KeyValueCollection userData = new KeyValueCollection();

            userData.Add("crmactivityid", activityid);
            userData.Add("crmactivitytype", activitytype);

            try
            {
                interactionServerProtocol.Open();

                RequestSubmit requestSubmit = RequestSubmit.Create(
                    interactionServerProtocol.ProxyId,
                        null,
                        null,
                        inboundQueue,
                        tenantID,
                        "crmemail",
                        "Inbound",
                        "InboundNew",
                        true,
                        System.DateTime.UtcNow,
                        userData,
                        null,
                        null,
                        null);

                IMessage response =
                    interactionServerProtocol.Request(requestSubmit);
                WriteToLog("Response: " + response.Name);

            }
            catch(Exception exception)
            {
                WriteToLog(
                    "Exception while sending request to interaction server: " +
                    exception.Message);
            }
-----------------------------------------------------------------------------------------------------------

But I believe that the using of existing channel with Interaction Server is more efficient method.
Currently, I use the existing channel with the server in this way:

-----------------------------------------------------------------------------------------------------------
            IChannelManager channelManager = container.Resolve<IChannelManager>();
            Genesyslab.Enterprise.Model.Channel.IClientChannel interactionServerChannel =
                      channelManager.Register(INTERACTION_SERVER_NAME, "WDE");
            InteractionServerProtocol interactionServerProtocol = (InteractionServerProtocol)interactionServerChannel.Protocol;

            try
            {
                RequestSubmit requestSubmit = RequestSubmit.Create(MEDIA_TYPE, INTERACTION_TYPE);

                requestSubmit.Queue = defaultQueue;
                requestSubmit.TenantId = agent.ConfPerson.Tenant.DBID;
                requestSubmit.InteractionSubtype = INTERACTION_SUBTYPE;
                requestSubmit.IsOnline = false;
                requestSubmit.ProxyClientId = interactionServerProtocol.ServerContext.ProxyId + 1;
                requestSubmit.UserData = userData;

                IMessage response = interactionServerProtocol.Request(requestSubmit);

                if (response != null && response.Name != "EventError")
                {
                    EventAck eventAck = (EventAck)response;     
                }
            }
            catch (Exception exception)
            {
                LogException(exception);
            }
-----------------------------------------------------------------------------------------------------------

As you can see, there is "requestSubmit.ProxyClientId = interactionServerProtocol.ServerContext.ProxyId + 1;" line of code in C#. Interaction Server does not create interaction without ProxyClientId determining. But using of "interactionServerProtocol.ServerContext.ProxyId + 1" is not entirely correct method.

Maybe, there is a more correct method to define ProxyClientId. In other words, how to use an existing channel with Interaction Server?

Please, advice.

Offline cavagnaro

  • Administrator
  • Hero Member
  • *****
  • Posts: 7639
  • Karma: 56330
Re: Using existing channel with Interaction Server
« Reply #1 on: January 21, 2016, 12:56:32 PM »
I think each interaction needs its own channel as there is a communication between IXN and your app to exchange data and see how it is behaving.
You can check how IWS behaves by checking IXN logs as well.