You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@activemq.apache.org by KateMacdonald <ka...@gmail.com> on 2012/10/29 18:02:52 UTC

NMS NetTxConnection fails to create a session when hostname includes a hyphen

All our local machines hostnames include a hyphen, e.g. "Machine-M1234".

This is causing an exception when I try to create a session from a
NetTxConnection as the GuidFromId() method is failing to parse the BrokerId
into a Guid because of this hyphen in the hostname; e.g.
"ID:MACHINE-M123-49158-1351527642035-0:1"

Renaming all our machines isn't an option. Other than downloading the
source, re-implementing this method and recompiling is there anything simple
I can do to fix this issue?

Thanks.

private static Guid GuidFromId(string id)
{
	// Remove the ID: prefix, that's non-unique to be sure
	string resId = id.TrimStart("ID:".ToCharArray());

	// Remaing parts should be host-port-timestamp-instance:sequence
	string[] parts = resId.Split(":-".ToCharArray());

	// We don't use the hostname here, just the remaining bits.
	int a = Int32.Parse(parts[1]);
	short b = Int16.Parse(parts[3]);
	short c = Int16.Parse(parts[4]);
	byte[] d = System.BitConverter.GetBytes(Int64.Parse(parts[2]));

	return new Guid(a, b, c, d);
}



--
View this message in context: http://activemq.2283324.n4.nabble.com/NMS-NetTxConnection-fails-to-create-a-session-when-hostname-includes-a-hyphen-tp4658395.html
Sent from the ActiveMQ - Dev mailing list archive at Nabble.com.

Re: NMS NetTxConnection fails to create a session when hostname includes a hyphen

Posted by KateMacdonald <ka...@gmail.com>.
Thanks for your responses. I've raised this Jira;
https://issues.apache.org/jira/browse/AMQNET-399 for the fix.



--
View this message in context: http://activemq.2283324.n4.nabble.com/NMS-NetTxConnection-fails-to-create-a-session-when-hostname-includes-a-hyphen-tp4658395p4658438.html
Sent from the ActiveMQ - Dev mailing list archive at Nabble.com.

Re: NMS NetTxConnection fails to create a session when hostname includes a hyphen

Posted by Jim Gomes <e....@gmail.com>.
That looks like it would work.

(As a side-note, I couldn't see the code snippet on the e-mail list.  I had
to click out to the nabble website in order to see it.  Weird.)

On Mon, Oct 29, 2012 at 4:24 PM, tabish121@gmail.com <ta...@gmail.com>wrote:

> Maybe this could do the trick:
>
>
>
>
>
> --
> View this message in context:
> http://activemq.2283324.n4.nabble.com/NMS-NetTxConnection-fails-to-create-a-session-when-hostname-includes-a-hyphen-tp4658395p4658425.html
> Sent from the ActiveMQ - Dev mailing list archive at Nabble.com.
>

Re: NMS NetTxConnection fails to create a session when hostname includes a hyphen

Posted by "tabish121@gmail.com" <ta...@gmail.com>.
Maybe this could do the trick:





--
View this message in context: http://activemq.2283324.n4.nabble.com/NMS-NetTxConnection-fails-to-create-a-session-when-hostname-includes-a-hyphen-tp4658395p4658425.html
Sent from the ActiveMQ - Dev mailing list archive at Nabble.com.

Re: NMS NetTxConnection fails to create a session when hostname includes a hyphen

Posted by Jim Gomes <e....@gmail.com>.
Hi Kate,

I don't see a work around that you can do for that without a code change.
 That function should be re-implemented to parse out the pieces that it
needs by working from right to left, instead of left to right.  If you want
to enter a JIRA for this, we can integrate a patch fix for it.

Best,
Jim

On Mon, Oct 29, 2012 at 10:02 AM, KateMacdonald <
kate.helen.macdonald@gmail.com> wrote:

> All our local machines hostnames include a hyphen, e.g. "Machine-M1234".
>
> This is causing an exception when I try to create a session from a
> NetTxConnection as the GuidFromId() method is failing to parse the BrokerId
> into a Guid because of this hyphen in the hostname; e.g.
> "ID:MACHINE-M123-49158-1351527642035-0:1"
>
> Renaming all our machines isn't an option. Other than downloading the
> source, re-implementing this method and recompiling is there anything
> simple
> I can do to fix this issue?
>
> Thanks.
>
> private static Guid GuidFromId(string id)
> {
>         // Remove the ID: prefix, that's non-unique to be sure
>         string resId = id.TrimStart("ID:".ToCharArray());
>
>         // Remaing parts should be host-port-timestamp-instance:sequence
>         string[] parts = resId.Split(":-".ToCharArray());
>
>         // We don't use the hostname here, just the remaining bits.
>         int a = Int32.Parse(parts[1]);
>         short b = Int16.Parse(parts[3]);
>         short c = Int16.Parse(parts[4]);
>         byte[] d = System.BitConverter.GetBytes(Int64.Parse(parts[2]));
>
>         return new Guid(a, b, c, d);
> }
>
>
>
> --
> View this message in context:
> http://activemq.2283324.n4.nabble.com/NMS-NetTxConnection-fails-to-create-a-session-when-hostname-includes-a-hyphen-tp4658395.html
> Sent from the ActiveMQ - Dev mailing list archive at Nabble.com.
>