Message Queue creation within NAV

kinekine Member Posts: 12,562
After some time I have problem I cannot solve myself in easy way and it is why I am asking our "worldwide shared NAV brain" called MIBUSO... 8)

I am working on some application using MSMQ within NAV. But I have problems with creation of the queue first time I want to use it. I have two possibilities:
MSMQ_BA.CreateQueue(...);
MSMQ_BA.OpenReceiveQueue(...,0,0);

If I use CreateQueue, the queue is created but next time it raise the error that the queue already exists. If I just use OpenReceiveQueue, first time, when the queue is not created, it show me error about insufficient permissions to create the queue. In documentation to the message bus component is written, that this command will create the queue if OS name is supplied.

I am using local queue (".\private$\queuename"). I am running it under Vista, but I tried to run NAV as administrator without success. Is there some way how to check if the queue exists without using external components? (just using the "standard" communication components). How you are solving that in your projects?

Manual creation is not possible, because the MSMQ is used on client side (all NAV clients).

Thanks for any tip...
Kamil Sacek
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.

Answers

  • Luc_VanDyckLuc_VanDyck Member, Moderator, Administrator Posts: 3,633
    I don't have much experience with queues, but I read the following in the on-line help:

    <start quote>
    IMSMQBusAdapter::OpenReceiveQueue

    [...]

    Parameter:
    [In] Name
    [In] Protocol
    [In] Mode
    Reflects the mode in which the queue will be opened. The mode options are:
    0: DIRECT (default value) - see the MSDN Platform SDK (Opening Queues with a Direct Format Name) for further information.
    1: PRIVATE
    2: PUBLIC

    When the protocol contains a value that has no meaning, the default OS protocol is used. When you set Mode to DIRECT, a FormatName (see below) is used. Any other Mode uses a PathName.

    FormatName example: AddressSpecification\PRIVATE\QueueName (for private queues)
    PathName example: .\Private$\myPrivateQueue
    <end quote>

    Maybe you need to use FormatName? Just my 2 cents.
    No support using PM or e-mail - Please use this forum. BC TechDays 2024: 13 & 14 June 2024, Antwerp (Belgium)
  • kinekine Member Posts: 12,562
    Thanks for the tip.

    I tried to use this formats:
    DIRECT=OS:compname\private$\queuename   //formatname
    DIRECT=OS:.\private$\queuename   //formatname
    compname\private$\queuename
    .\private$\queuename
    DIRECT=OS:compname\private\queuename   //formatname
    DIRECT=OS:.\private\queuename   //formatname
    compname\private\queuename
    .\private\queuename
    

    But with negative effect. The errors differs in some cases (remote computer is not available - but I am using . or local comp. name 8) ). But the queue was never created automatically. My be Vista problem... ](*,)
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • kinekine Member Posts: 12,562
    And one additional info: in MSMQ permissions has the local computer account full permissions to create and admin queues... :|
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • kinekine Member Posts: 12,562
    For now I used workaround (new codeunit called in IF statement creating the queue before opening it).

    But if someone have better solution and want it to share it with us, please, post it.

    8)
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • Luc_VanDyckLuc_VanDyck Member, Moderator, Administrator Posts: 3,633
    Clever workaround you created!
    No support using PM or e-mail - Please use this forum. BC TechDays 2024: 13 & 14 June 2024, Antwerp (Belgium)
  • DenSterDenSter Member Posts: 8,305
    The MSMQ object model is available in C/AL, so if you can find VB sample code, you can use it in C/AL. I've used it to open transactional queues, to use double byte character strings, to peek (i.e. look at messages without committing them), to use different label values, etcetera. I have not programmed it to actually create a queue, but I am certain that it is an easy task if you use the object model directly. I have a sample somewhere in my old files, but it would take quite some time to find it. Let me know if you can't figure it out and I'll go on a fishing expedition :mrgreen:
Sign In or Register to comment.