You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@qpid.apache.org by SanathPrudhvi <Sa...@mahindrasatyam.com> on 2011/02/07 07:49:26 UTC

Failed to connect

Hi,

   I am using C++ broker with .net client

I am getting error while connecting to my C++ broker.
Error is "Failed to Connect". I am using default settings.

server name : localhost
port number : 5672

thanks,
-Sanath
-- 
View this message in context: http://apache-qpid-users.2158936.n2.nabble.com/Failed-to-connect-tp5999408p5999408.html
Sent from the Apache Qpid users mailing list archive at Nabble.com.

---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:users-subscribe@qpid.apache.org


Re: Failed to connect

Posted by SanathPrudhvi <Sa...@mahindrasatyam.com>.
Dear Ted,

          When I run my application on same machine it is working fine.
But when I run the code on other machine, I got "Specified Module Could not
be found"
error. I am using VS 2008 with XP SP3 on both machines. apache qpid version
is 0.8.


          I am send the code for your reference. ( This is a window
application).
In this below code "cmbEvent_SelectedIndexChanged" function, when I tried to 
create the object, it is showing the specified error.

using System;
using Org.Apache.Qpid.Messaging;
using System.Text;
using System.Collections;
using System.Threading;
using CommonInterface;
using POCReports;

namespace AMQPPOC
{
    public class AMQP : IMessageQueuing
    {

        #region Private Members

        Connection connection = null;
        Session session = null;
        Sender sender = null;
        Receiver receiver = null;
        Message message = null;
        Address address = null;


        bool flag = true;
        string serverName = null;
        string portNumber = null;
        string requestQueue = null;
        string responseQueue = null;
        string userName = null;
        string password = null;

        StringBuilder sbMessages = null;

        #endregion

        #region Constructor

        public AMQP()
        {
            // set the default selected test as "Message Throughput"
            //SelectedTest = TestType.MessageThroughput;
        }

        #endregion

        #region IMessageQueuing Members

        public TestType SelectedTest
        {
            get;
            set;
        }

        public ReceivedMessageDetails ReceivedDetails
        {
            get;
            set;
        }

        /// <summary>
        /// 
        /// </summary>
        /// 
        public void GetConfigurationDetails(Hashtable htConfigDetails)
        {

            if (htConfigDetails != null)
            {

                serverName = htConfigDetails["server"].ToString();
                portNumber = htConfigDetails["port"].ToString();
                requestQueue = htConfigDetails["request"].ToString();
                responseQueue = htConfigDetails["response"].ToString();
                userName = htConfigDetails["username"].ToString();
                password = htConfigDetails["password"].ToString();
            }

        }

        protected void cmbEvent_SelectedIndexChanged(object sender,
EventArgs e)
        {
                     AMQP q = new AMQP();
        }

        protected void start_click(object sender, EventArgs e)
        {
                StartService();
         }

        /// <summary>
        /// 
        /// </summary>
        public void StartService()
        {

            try
            {
                //start services / Brokers that are related to the event
mechanism
                connection = new Connection(serverName + ":" + portNumber);
                connection.Open();

                // create session for AMQP
                session = connection.CreateSession();
            }
            catch (Exception ex)
            {
                System.Windows.Forms.MessageBox.Show("AMQP Code \r\n" +
ex.Message);
                throw ex;
            }
        }

        /// <summary>
        /// 
        /// </summary>
        public void StopService()
        {

            try
            {
                if (connection != null && session != null)
                {
                    // close session and connection..
                    if (sender != null)
                    {
                        sender.Close();
                        sender.Dispose();
                    }

                    if (receiver != null)
                    {
                        receiver.Close();
                        receiver.Dispose();
                    }

                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

        }

        /// <summary>
        /// 
        /// </summary>
        /// 
        public void SetServerConfiguration()
        {

            string sbReceivedMessages = null;
            sbMessages = new StringBuilder();

            try
            {
                // create receiver ...
                if (receiver == null)
                {
                    // if selected test is for priority test
                    if (SelectedTest == TestType.MessagePriorityLatency)
                        receiver = session.CreateReceiver(requestQueue +
                            "; {create:always,
node:{x-declare:{arguments:{x-qpid-priorities:10,qpid-fairshare:5}}}}");
                    else
                        receiver = session.CreateReceiver(requestQueue +
                            "; {create:always}");
                }

                // create sender incase of request / response type...
                Message responseMessage = new Message();
                int count = 1;
                int totalMessages = 1;

                while (flag)
                {

                    // display received message in text box..
                    try
                    {
                        // wait for unlimited time to receive a message
                        message = receiver.Fetch();

                        if ((SelectedTest == TestType.MessageThroughput) ||
                            (SelectedTest == TestType.RPCThroughput))
                        {
                            if (count == totalMessages)
                            {
                                sbReceivedMessages = String.Format(
                                    "{0: hh:mm:ss.fff}, {1} ", DateTime.Now,
                                    message.Subject);
                                ReceivedDetails(sbReceivedMessages);

                                totalMessages = int.Parse(message.UserId);
                            }

                            // if test type is RPC, give response to each
request
                            if (SelectedTest == TestType.RPCThroughput)
                            {
                                if ((address == null) ||
                                    (message.ReplyTo.Name != address.Name))
                                {
                                    address = message.ReplyTo;
                                    sender = session.CreateSender(address);
                                }

                                if (address != null)
                                {
                                   
responseMessage.SetContent(String.Format(
                                        "Response , {0}",
                                        message.GetContent()));
                                    responseMessage.Subject =
message.Subject;

                                    sender.Send(responseMessage, false);

                                    // record the sent/response time..
                                    if (count == 1 || count ==
totalMessages)
                                    {
                                       
frmReports.sbMessageReports.AppendLine(
                                            String.Format("{0 :
hh:mm:ss.fff} {1} , {2}",
                                            DateTime.Now, " Response ",
                                            message.Subject));
                                    }
                                    session.Acknowledge();
                                }
                            }
                        }

                        // display each message latency ...
                        if ((SelectedTest == TestType.MessageLatency) ||
                            (SelectedTest ==
TestType.MessagePriorityLatency))
                        {

                            if (count == 1)
                                totalMessages = int.Parse(message.UserId);

                            sbMessages.AppendLine(String.Format(
                            "{0: hh:mm:ss.fff} , {1} ", DateTime.Now,
                            message.Subject));

                            if (SelectedTest ==
TestType.MessagePriorityLatency)
                            {

                                address = message.ReplyTo;
                                sender = session.CreateSender(address);

                                // send the high priority message with same
priority
                                Message msgResponse = new Message();
                                msgResponse.SetContent((String.Format("{0}",
                                    message.GetContent())));
                                msgResponse.Subject = message.Subject;

                                if (message.Priority == 9)
                                    msgResponse.Priority = 9;

                                sender.Send(msgResponse);

                                frmReports.sbMessageReports.AppendLine(
                                    String.Format("{0 : hh:mm:ss.fff}, {1},
{2}",
                                    DateTime.Now, " Response ",
message.Subject));
                            }

                            if (count >= totalMessages)
                                ReceivedDetails(sbMessages.ToString());

                        }

                        ++count;
                        if (count > totalMessages)
                        {
                            flag = false;
                            System.Windows.Forms.MessageBox.Show("No
Messages to fetch");
                        }
                    }
                    catch (Exception ex)
                    {
                        flag = false;
                        throw ex;
                    }
                }
                frmReports.sbMessageReports.Insert(0, "Response Sent\r\n");
            }
            catch (Exception qex2)
            {
                System.Windows.Forms.MessageBox.Show(qex2.Message);
            }
        }

        /// <summary>
        /// 
        /// </summary>
        public void SetClientConfiguration()
        {

            try
            {
                // create sender queue .. to send the addresses
                sender = session.CreateSender(requestQueue);

                // set request message...
                message = new Org.Apache.Qpid.Messaging.Message();
                Address response = null;

                // if selected test type is request / response
                if ((SelectedTest == TestType.RPCThroughput) ||
                    (SelectedTest == TestType.MessagePriorityLatency))
                {

                    if (SelectedTest == TestType.MessagePriorityLatency)
                    {
                        // create queue to receive response messages from
server...
                        response = new Address("#" + responseQueue +
                            "; {create:always, delete:always,
node:{x-declare:{arguments:{x-qpid-priorities:10,qpid-fairshare:5}}}}");
                    }
                    else
                    {
                        // create queue to receive response messages from
server...
                        response = new Address("#" + responseQueue +
                            "; {create:always, delete:always}");
                    }
                    // create receiver queue..
                    receiver = session.CreateReceiver(response);
                    message.ReplyTo = response;
                }

            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        /// <summary>
        /// 
        /// </summary>
        /// 
        /// 
        /// 
        /// 
        public void SendRequest(string request, int messageCount,
            long messageSize, int highPriorityPosition)
        {

            try
            {

                if ((SelectedTest == TestType.RPCThroughput) ||
                    (SelectedTest == TestType.MessagePriorityLatency))
                {

                    Thread t = new Thread(
                        new
ParameterizedThreadStart(ReceiveReponseMessages));
                    t.Start(messageCount);
                }

                sender.Capacity = 50000;
                message.UserId = messageCount.ToString();
                int position = highPriorityPosition;

                for (int i = 1; i <= messageCount; i++)
                {

                    message.SetContent(request + " " + i.ToString());
                    message.Subject = i.ToString();

                    // set default message priority...
                    message.Priority = 5;

                    if ((SelectedTest == TestType.MessagePriorityLatency) &&
                        (i == position))
                    {
                        message.Priority = 9;
                        position = highPriorityPosition + position;
                    }

                    sender.Send(message, false);


                    if ((SelectedTest == TestType.MessageLatency) ||
                        (SelectedTest == TestType.MessagePriorityLatency))
                    {
                        frmReports.sbMessageReports.AppendLine(String.Format
                        ("{0 : hh:mm:ss.fff}, {1}, {3}, {2}", DateTime.Now,
" request ",
                        message.Priority, i));
                    }

                    if ((SelectedTest == TestType.RPCThroughput) ||
                        (SelectedTest == TestType.MessageThroughput))
                    {
                        if (i == 1 || i == messageCount)
                        {
                           
frmReports.sbMessageReports.AppendLine(String.Format
                            ("{0 : hh:mm:ss.fff}, {1}, {3} , {2}",
DateTime.Now, " request ",
                            message.Priority, i));
                        }
                    }

                    // send acknowledgement to client upon reaching the
destination
                    session.Acknowledge();
                }
                frmReports.sbMessageReports.Insert(0, "Request Sent \r\n");

            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        // if user selects Request/Resposnse or Message Priority Latency
tests
        // wait for response messages from server
        private void ReceiveReponseMessages(object totalMessages)
        {

            // wait for server response, incase selected test is
request/response
            StringBuilder sbResponse = new StringBuilder();
            int count = 1;
            int messageCount = (int)totalMessages;

            while (flag)
            {

                try
                {
                    Message response = receiver.Fetch();

                    if ((SelectedTest == TestType.MessageThroughput) ||
                        (SelectedTest == TestType.RPCThroughput))
                    {

                        if (count == 1 || count == messageCount)
                        {
                            sbResponse.AppendLine(String.Format(
                                "{0: hh:mm:ss.fff}, {1}, {2}", DateTime.Now,
" Response ",
                                response.Subject));

                        }
                    }

                    if ((SelectedTest == TestType.MessageLatency) ||
                        (SelectedTest == TestType.MessagePriorityLatency))
                    {

                        sbResponse.AppendLine(String.Format(
                                "{0: hh:mm:ss.fff}, {1}, {2}", DateTime.Now,
" Response ",
                                response.Subject));
                    }

                    if (count >= messageCount)
                    {
                        ReceivedDetails(sbResponse.ToString());
                        sbResponse.Remove(0, sbResponse.Length);
                    }

                }
                catch (Exception ex)
                {
                    flag = false;
                    throw ex;
                }

                ++count;

                if (count > messageCount)
                {
                    flag = false;
                    System.Windows.Forms.MessageBox.Show("No Messages to
fetch");
                }
            }

        }

        #endregion
    }
}

thanks,
-Sanath

-- 
View this message in context: http://apache-qpid-users.2158936.n2.nabble.com/Failed-to-connect-tp5999408p6023122.html
Sent from the Apache Qpid users mailing list archive at Nabble.com.

---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:users-subscribe@qpid.apache.org


Re: Failed to connect

Posted by Ted Ross <tr...@redhat.com>.
Sanath,

Can you please provide us with more detailed information?  Are you 
running the broker and the clients on the same system or different 
systems?  Which OS are you running the broker on?  Which .net client are 
you using?  Are you trying to run one of the .net examples or your own 
application?

Thanks,

-Ted

On 02/09/2011 11:37 AM, SanathPrudhvi wrote:
> No.
>
> thanks,
> -Sanath
> ________________________________
> From: Carl Trieloff [via Apache Qpid users] [ml-node+6000346-425776785-310978@n2.nabble.com]
> Sent: Monday, February 07, 2011 7:27 PM
> To: Sanath_Prudhvi
> Subject: Re: Failed to connect
>
>
>
> do any of the other clients connect?  i.e. firewall, iptables, etc ??
>
> Carl.
>
>
> On 02/07/2011 01:49 AM, SanathPrudhvi wrote:
>
>> Hi,
>>
>>      I am using C++ broker with .net client
>>
>> I am getting error while connecting to my C++ broker.
>> Error is "Failed to Connect". I am using default settings.
>>
>> server name : localhost
>> port number : 5672
>>
>> thanks,
>> -Sanath
>
> ---------------------------------------------------------------------
> Apache Qpid - AMQP Messaging Implementation
> Project:      http://qpid.apache.org
> Use/Interact: mailto:[hidden email]<UrlBlockedError.aspx>
>
>
>
> ________________________________
> If you reply to this email, your message will be added to the discussion below:
> http://apache-qpid-users.2158936.n2.nabble.com/Failed-to-connect-tp5999408p6000346.html
> To unsubscribe from Failed to connect, click here<http://apache-qpid-users.2158936.n2.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=5999408&code=U2FuYXRoX1BydWRodmlAbWFoaW5kcmFzYXR5YW0uY29tfDU5OTk0MDh8MTA1NzcwOTIwMA==>.
>
> ________________________________
> DISCLAIMER:
> This email (including any attachments) is intended for the sole use of the intended recipient/s and may contain material that is CONFIDENTIAL AND PRIVATE COMPANY INFORMATION. Any review or reliance by others or copying or distribution or forwarding of any or all of the contents in this message is STRICTLY PROHIBITED. If you are not the intended recipient, please contact the sender by email and delete all copies; your cooperation in this regard is appreciated.
>


---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:users-subscribe@qpid.apache.org


RE: Failed to connect

Posted by SanathPrudhvi <Sa...@mahindrasatyam.com>.
No.

thanks,
-Sanath
________________________________
From: Carl Trieloff [via Apache Qpid users] [ml-node+6000346-425776785-310978@n2.nabble.com]
Sent: Monday, February 07, 2011 7:27 PM
To: Sanath_Prudhvi
Subject: Re: Failed to connect



do any of the other clients connect?  i.e. firewall, iptables, etc ??

Carl.


On 02/07/2011 01:49 AM, SanathPrudhvi wrote:

> Hi,
>
>     I am using C++ broker with .net client
>
> I am getting error while connecting to my C++ broker.
> Error is "Failed to Connect". I am using default settings.
>
> server name : localhost
> port number : 5672
>
> thanks,
> -Sanath


---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:[hidden email]<UrlBlockedError.aspx>



________________________________
If you reply to this email, your message will be added to the discussion below:
http://apache-qpid-users.2158936.n2.nabble.com/Failed-to-connect-tp5999408p6000346.html
To unsubscribe from Failed to connect, click here<http://apache-qpid-users.2158936.n2.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=5999408&code=U2FuYXRoX1BydWRodmlAbWFoaW5kcmFzYXR5YW0uY29tfDU5OTk0MDh8MTA1NzcwOTIwMA==>.

________________________________
DISCLAIMER:
This email (including any attachments) is intended for the sole use of the intended recipient/s and may contain material that is CONFIDENTIAL AND PRIVATE COMPANY INFORMATION. Any review or reliance by others or copying or distribution or forwarding of any or all of the contents in this message is STRICTLY PROHIBITED. If you are not the intended recipient, please contact the sender by email and delete all copies; your cooperation in this regard is appreciated.

-- 
View this message in context: http://apache-qpid-users.2158936.n2.nabble.com/Failed-to-connect-tp5999408p6008382.html
Sent from the Apache Qpid users mailing list archive at Nabble.com.

Re: Failed to connect

Posted by Carl Trieloff <cc...@redhat.com>.

do any of the other clients connect?  i.e. firewall, iptables, etc ??

Carl.


On 02/07/2011 01:49 AM, SanathPrudhvi wrote:
> Hi,
>
>     I am using C++ broker with .net client
>
> I am getting error while connecting to my C++ broker.
> Error is "Failed to Connect". I am using default settings.
>
> server name : localhost
> port number : 5672
>
> thanks,
> -Sanath


---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:users-subscribe@qpid.apache.org