[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 353
  • Last Modified:

MSMQ to remote server

I am trying to path msmq messages to a specific terminal server if the user session is in terminal server 1(TS1)  then the message should queue to the local machine if the if in any other it should queue to TS1. My code is not quite correct I get a name error with this code. Can anyone help with the correct syntax?

If  Environment.MachineName = "TS1" Then
            toMyQueuePath = System.Configuration.ConfigurationManager.AppSettings("ToMyQueuePath")
            _toMyQueue = New MessageQueue(toMyQueuePath)
            _toMyQueue.Formatter = New XmlMessageFormatter(New Type() {GetType(XmlDocument)})
        Else
            toMyQueuePath = System.Configuration.ConfigurationManager.AppSettings("TS1\ToMyQueuePath")
            _toMyQueue = New MessageQueue(toMyQueuePath)
            _toMyQueue.Formatter = New XmlMessageFormatter(New Type() {GetType(XmlDocument)})
        End If
0
JoeBo747
Asked:
JoeBo747
  • 2
1 Solution
 
Dennis AriesCEO @ Arkro ITCommented:
toMyQueuePath = System.Configuration.ConfigurationManager.AppSettings("TS1\ToMyQueuePath") ?
I think you are trying to:
toMyQueuePath = "TS1\\" + System.Configuration.ConfigurationManager.AppSettings("ToMyQueuePath")
 
The key you try to read from the appsettings does not exist.
0
 
JoeBo747Author Commented:
Hi djjaries:

I have given up on the method I was attempting and now have the following to write to the queue:

    Dim q As MessageQueue
                          q = New MessageQueue("FormatName:Direct=OS:ts1\Private$\JobsTransfer")
                    Dim m As New Messaging.Message()
            m.Body = document
            m.Label = "Jobs Test Message"
            q.Formatter = New XmlMessageFormatter(New Type() {GetType(XmlDocument)})
            q.Send(m)
                     q.Close()
The code throughs no errors but the message does not get written to the queue. Can you see why.
Regards
JoeBo
0
 
Dennis AriesCEO @ Arkro ITCommented:
Try to format the message instead of the queue. Formatting the queue is used for receiving the messages.

Dim q As MessageQueue
        q = New MessageQueue("FormatName:Direct=OS:ts1\Private$\JobsTransfer")
        Dim m As New Messaging.Message(document, New XmlMessageFormatter())
        m.Body = document
        m.Label = "Jobs Test Message"        
        q.Send(m)
        q.Close()

Open in new window

0

Featured Post

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now