ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum IndexIBM MQ API SupportMQ Event like MSMQ

Post new topicReply to topic
MQ Event like MSMQ View previous topic :: View next topic
Author Message
goodman
PostPosted: Sat Jul 21, 2007 6:52 pm Post subject: MQ Event like MSMQ Reply with quote

Newbie

Joined: 21 Jul 2007
Posts: 3

Hello, theres
I'm new in MQSeries. I want to retrieve messages in mqqueue using c#.
Is it possible to using event (like MSMQ event / enable notification) when new message is arrival ? any code example ? Besides, I must handle connection broken problem, if network problem be solved, the new coming message also can be retrieve again.

Regards,
goodman
Back to top
View user's profile Send private message
Michael Dag
PostPosted: Sat Jul 21, 2007 11:02 pm Post subject: Reply with quote

Jedi Knight

Joined: 13 Jun 2002
Posts: 2607
Location: The Netherlands (Amsterdam)

if the Queuemanager is not local you need to connect and do a get with wait, when connection is broken (rc 2009): reconnect.

if the Queuemanager is local you can use triggering
_________________
Michael



MQSystems Facebook page
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
jefflowrey
PostPosted: Sun Jul 22, 2007 3:39 am Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

Michael Dag wrote:
if the Queuemanager is not local you need to connect and do a get with wait, when connection is broken (rc 2009): reconnect.

if the Queuemanager is local you can use triggering


Or just run a client trigger monitor...

Or use the .NET Monitor...

Or use an MDB in a Java App Server ...
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
goodman
PostPosted: Sun Jul 22, 2007 4:52 am Post subject: Reply with quote

Newbie

Joined: 21 Jul 2007
Posts: 3

Michael Dag wrote:
if the Queuemanager is not local you need to connect and do a get with wait, when connection is broken (rc 2009): reconnect.

if the Queuemanager is local you can use triggering


Thanks a lot ! Just do an get with wait, catch the exception when connection broken. ( if the queue manager is stopped or stopping the rc code is different ? ) , all that I must do is reconnect when mq exceptions occured?

all I have to do is writting a .net windows form to process messages, show messages, is using .net monitor also ok ( mq server is on remote site)?? if possible how to achieve ? any example ?

When I worked with MSMQ, I can use some events with queue( end receive, but with MQSeries .net library doesn't provide any event ? must define on my own? any example ?? Or just using another thread to watch if message available.)
like the "postcard example "
http://blogs.msdn.com/dotnetinterop/archive/2004/11/08/net-and-mqseries.aspx it's a very good sample I found, are there any best practice example about .net and MQSeries available ?


Regards,
goodman
Back to top
View user's profile Send private message
Vitor
PostPosted: Sun Jul 22, 2007 6:03 am Post subject: Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

goodman wrote:
Thanks a lot ! Just do an get with wait, catch the exception when connection broken. ( if the queue manager is stopped or stopping the rc code is different ? ) , all that I must do is reconnect when mq exceptions occured?


Yes, there are specific codes for queue manager stopping. Be sure to include "fail if quiecseing" as a get option.

goodman wrote:

all I have to do is writting a .net windows form to process messages, show messages, is using .net monitor also ok ( mq server is on remote site)?? if possible how to achieve ? any example ?


There are sample with the server install, and on the web

goodman wrote:

When I worked with MSMQ, I can use some events with queue( end receive, but with MQSeries .net library doesn't provide any event ? must define on my own? any example ?? Or just using another thread to watch if message available.)


People have mentioned triggering before.
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
goodman
PostPosted: Sun Jul 22, 2007 11:47 pm Post subject: Reply with quote

Newbie

Joined: 21 Jul 2007
Posts: 3

I try to write a .net monitor for writting every message to file.

but when I using runmqdnm to attach the dll, exception throws

here are my simple code:

Code:


using System;
using System.Configuration;
using System.IO;
using System.Text;
using DJLibrary.Log;
using IBM.WMQ;
using IBM.WMQMonitor;

namespace mqdnm
{
   /// <summary>
   /// Summary description for MQToFile.
   /// </summary>
   public class MQToFile : IMQObjectTrigger
   {
      private string m_strFileName;

      public MQToFile()
      {
         InitMQMonitor();
         Logger.LogInfo(m_strFileName);
      }

      private void InitMQMonitor()
      {
         string strTmp = ConfigurationSettings.AppSettings["OutPutFolder"];
         if (strTmp != null)
         {
            while (strTmp.EndsWith("\\"))
               strTmp = strTmp.Substring(0, strTmp.Length - 1);
         }
         else
         {
            strTmp = AppDomain.CurrentDomain.BaseDirectory;
         }

         EnsureFolder(strTmp);
         m_strFileName = String.Format("{0}\\PutOrder_{1:yyyyMMdd}.txt", strTmp, DateTime.Today);
      }

      private void EnsureFolder(string strTmp)
      {
         if (!Directory.Exists(strTmp))
            Directory.CreateDirectory(strTmp);
      }

      public void Execute(MQQueueManager qmgr, MQQueue queue, MQMessage message, string param)
      {
         // how to reconnect if error occur ?
         Logger.LogInfo("Execute Body");
         try
         {
            using (StreamWriter sw = new StreamWriter(m_strFileName, true, Encoding.GetEncoding(950)))
            {
               sw.WriteLine(message.ReadString(message.MessageLength));
            }
         }
         catch (MQException mqex)
         {
            Logger.LogException(mqex);
         }
         catch (Exception ex)
         {
            Logger.LogException(ex);
         }
      }
   }
}




error in eventlog

Ä .NET Framework &N 'Ÿo·¨Ä½M¼þ mqdnm, Version=1.0.2760.28154, Culture=neutral, PublicKeyToken=e22ce4ebe641ac11 ÝdÈëÐÍ„e MQToFile¡£' ÊÕµ½·ÇîAÆÚµÄ®³£ î›r

‘ªÓóÌʽÊÕµ½í×Ô»ùµA .NET Framework µÄ®³£ î›r£¬ß@í—®³£ î›rµÄÏàêPÙYӍÈçÏ£º&N System.TypeLoadException: Ÿo·¨Ä½M¼þ mqdnm, Version=1.0.2760.28154, Culture=neutral, PublicKeyToken=e22ce4ebe641ac11 ÝdÈëÐÍ„e MQToFile¡£
at System.Reflection.Assembly.GetType(String name, Boolean throwOnError)
at runmqdnm.DotNetMonitorApp.InitInstance()


What's the problem ?

ps. my os is Traditional Chinese, so the error msg ...., besides using .net 1.1

Regards,
goodman
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Mon Jul 23, 2007 2:40 am Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20756
Location: LI,NY

I think you need to read much more in the manuals to understand what the trigger monitor does...

You could just as well use the JMS/XMS model and have a MessageListener put onto the queue. You'd need an ExceptionListener as well on the connection...

Enjoy
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
jefflowrey
PostPosted: Mon Jul 23, 2007 2:44 am Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

The .NET Monitor is not a Trigger Monitor, FJ. It's the equivalent to an MDB Listener Port.

I don't know what's wrong with Goodman's code - but it looks more like a .NET coding problem than an MQ problem. Or perhaps an issue with registering the code with the .NET Monitor properly.

But I know about as much about .NET as Vitor knows about Java - which is to say just enough to make *big* errors.
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Mon Jul 23, 2007 2:49 am Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20756
Location: LI,NY

Could be that he has a version mismatch, i.e. the .NET monitor still relying on the underlying C client /vs the fully managed .NET client ???

Sorry can't read any chinese...
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:
Post new topicReply to topic Page 1 of 1

MQSeries.net Forum IndexIBM MQ API SupportMQ Event like MSMQ
Jump to:



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Protected by Anti-Spam ACP


Theme by Dustin Baccetti
Powered by phpBB 2001, 2002 phpBB Group

Copyright MQSeries.net. All rights reserved.