 |
|
 |
Hi,
Can you please send me or post the code for assembly1 and assembly2. I got the same type of work but I don't find the code about assemblies. So, can you please post the code for assemblies. I am new to MSMQ. Please help me out, I need very urgent.
|
|
|
|
 |
|
 |
i have condition that need to read messages continuously that contains byte data i convert from byte to structure and then insert data into sqlserver.
and numbers of queues generated in 1 mins about 1500. If read continuously queue, cpu goes on 30%, and after some time it stopped.
I need to read queue in high volume upto 4 hrs.
bool ProcessStatus; //process
Thread _UDPthreadConsme;
private void btn_receive_Click(object sender, EventArgs e)
{
if (MessageQueue.Exists(@".\private$\myquelocal"))
{
ThreadStart _processrcs = new ThreadStart(receivemessages);
_UDPthreadConsme = new Thread(_processrcs);
ProcessStatus = true;
_UDPthreadConsme.Start();
}
}
private void receivemessages()
{
MessageBox.Show("Start");
while (ProcessStatus)
{
try
{
// Connect to the a queue on the local computer.
MessageQueue myQueue = new MessageQueue(@".\private$\myquelocal");
System.Messaging.Message[] myMessagecount = myQueue.GetAllMessages();
if (myMessagecount.Length <= 0)
return;
myQueue.Formatter = new BinaryMessageFormatter();
// Receive and format the message.
System.Messaging.Message myMessage = myQueue.Receive();
byte[] buffer = (byte[])myMessage.Body;
//here convert byte to structure
TBCastMessageHeader bcastHeader = new TBCastMessageHeader(); IntPtr bcastHeaderPtr; bcastHeaderPtr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(TBCastMessageHeader)));
Marshal.Copy(buffer, 0, bcastHeaderPtr, buffer.Length);
bcastHeader = (TBCastMessageHeader)(Marshal.PtrToStructure(bcastHeaderPtr, typeof(TBCastMessageHeader)));
// end convert
// here i convert buffer to its related structure and then insert the values in database sqlserver.
}
}
|
|
|
|
 |
|
 |
Where is the assembly1 code?
|
|
|
|
 |
|
 |
Hi,
my one application is storing data in database table and another application(windows service) is polling this database at periodic interval to fetch this data and does some work on it.
can I use MSMQ for this perticular application.
will it improve the performace of my windows service..
Apps
|
|
|
|
 |
|
 |
Yes! you can do that. In that case you have to create "Command" object design patterns. You can have a custom class defined (XML serializable) and store objects/ instances of that class in the queue. While reading from the queue, use typecasting to 'read' the object properties. Check MSDN for using Command Patterns in Queuing.
Anupam
|
|
|
|
 |
|
 |
Can I store record having more than one fields(as we dtore it in database table) in message queue
apps
|
|
|
|
 |
|
 |
what component did you use to process the reports? RAS, Enterprise or CR.Net? If CR.Net, what, if anything, did you do to handle large volumes of jobs? Did you create a ReportProcessing Service of sorts? Seems to me that you'd want to have mutliple instances of CR processing jobs at once, but limit the total number of instances in some way. Moreover, you'd also want to have a pool of these in memory that are reused. Did you find a way to add additional machines to help w/ processing?
thanks.
|
|
|
|
 |
|
 |
i have created a window service in C# and define some function in it. now my question is that how can i call these functions from asp.net or in windows another application.
looking for your replies
Thanks
i am a student and doing my bcs and i am in my last year and wana make some work in vc++
so i wana make any help form here so that is why
i am here to learn from u peoples
i am a student and doing my bcs and i am in my last year and wana make some work in vc++
so i wana make any help form here so that is why
i am here to learn from u peoples
i am a student and doing my bcs and i am in my last year and wana make some work in vc++
so i wana make any help form here so that is why
|
|
|
|
 |
|
 |
Hi,
Thanks for the article. I have a suggestion which might be useful. Instead of starting a timer. I suggest starting a thread that does something as follows. If any one finds it bad please let me know at factpandit@yahoo.com [ ]
---------------------------------------------------------------------------
OnStart: "QueuePath" is the string that contains the queue path and m_messageQueue is the "MessageQueue" class object. m_serviceThread is an object of type System.Threading.Thread.
---------------------------------------------------------------------------
protected override void OnStart(string[] args)
{
// Open Message Queue:
if (MessageQueue.Exists(QueuePath))
m_messageQueue = new MessageQueue(QueuePath);
else
m_messageQueue = MessageQueue.Create(QueuePath);
m_messageQueue.Formatter = new XmlMessageFormatter(new Type[]{
typeof(string)});
// Create a service thread:
m_serviceThread = new Thread(new ThreadStart(
MSMQServiceThreadDelegate));
// Start Service Thread:
m_serviceThread.Start();
}
---------------------------------------------------------------------------
OnStop:m_stopServiceEvent is an event of type "ManualResetEvent".
---------------------------------------------------------------------------
protected override void OnStop()
{
m_stopServiceEvent.Set();
// Wait for a max.of ten seconds for the the thread to stop.
m_serviceThread.Join(10000);
// If still alive; Get rid of the thread.
if (m_serviceThread.IsAlive)
{
m_serviceThread.Abort();
}
m_messageQueue.Close();
//MessageQueue.Delete(QueuePath);
m_messageQueue = null;
m_serviceThread = null;
}
---------------------------------------------------------------------------
MSMQServiceThreadDelegate: ProcessMessage(Message message) processes the actual message.
---------------------------------------------------------------------------
private void MSMQServiceThreadDelegate()
{
IAsyncResult result = null;
Message message = null;
WaitHandle[] waitHandleArray = new WaitHandle[2];
waitHandleArray[0] = m_stopServiceEvent;//Service Thread Stop Event:
bool bReceiveMessages = true;
while (bReceiveMessages)
{
try
{
result = m_messageQueue.BeginReceive();
waitHandleArray[1] = result.AsyncWaitHandle;
//If the serivice is stopped i.e. WaitAny returns 0; Stop Thread
if (WaitHandle.WaitAny(waitHandleArray) == 0)
bReceiveMessages = false;
else
{
message = m_messageQueue.EndReceive(result);
ProcessMessage(message);// Do your stuff
}
}
catch (Exception e)
{
if (message != null)
m_messageQueue.Send(message);
bReceiveMessages = false;
}
}
}
|
|
|
|
 |
|
 |
i have condition that need to read messages continuously that contains byte data i convert from byte to structure and then insert data into sqlserver.
and numbers of queues generated in 1 mins about 1500. If read continuously queue, cpu goes on 30%, and after some time it stopped.
I need to read queue in high volume upto 4 hrs.
bool ProcessStatus; //process
Thread _UDPthreadConsme;
private void btn_receive_Click(object sender, EventArgs e)
{
if (MessageQueue.Exists(@".\private$\myquelocal"))
{
ThreadStart _processrcs = new ThreadStart(receivemessages);
_UDPthreadConsme = new Thread(_processrcs);
ProcessStatus = true;
_UDPthreadConsme.Start();
}
}
private void receivemessages()
{
MessageBox.Show("Start");
while (ProcessStatus)
{
try
{
// Connect to the a queue on the local computer.
MessageQueue myQueue = new MessageQueue(@".\private$\myquelocal");
System.Messaging.Message[] myMessagecount = myQueue.GetAllMessages();
if (myMessagecount.Length <= 0)
return;
myQueue.Formatter = new BinaryMessageFormatter();
// Receive and format the message.
System.Messaging.Message myMessage = myQueue.Receive();
byte[] buffer = (byte[])myMessage.Body;
//here convert byte to structure
TBCastMessageHeader bcastHeader = new TBCastMessageHeader(); IntPtr bcastHeaderPtr; bcastHeaderPtr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(TBCastMessageHeader)));
Marshal.Copy(buffer, 0, bcastHeaderPtr, buffer.Length);
bcastHeader = (TBCastMessageHeader)(Marshal.PtrToStructure(bcastHeaderPtr, typeof(TBCastMessageHeader)));
// end convert
// here i convert buffer to its related structure and then insert the values in database sqlserver.
}
}
|
|
|
|
 |
|
 |
i have condition that need to read messages continuously that contains byte data i convert from byte to structure and then insert data into sqlserver.
and numbers of queues generated in 1 mins about 1500. If read continuously queue, cpu goes on 30%, and after some time it stopped.
I need to read queue in high volume upto 4 hrs.
bool ProcessStatus; Thread _UDPthreadConsme;
private void btn_receive_Click(object sender, EventArgs e)
{
if (MessageQueue.Exists(@".\private$\myquelocal"))
{
ThreadStart _processrcs = new ThreadStart(receivemessages);
_UDPthreadConsme = new Thread(_processrcs);
ProcessStatus = true;
_UDPthreadConsme.Start();
}
}
private void receivemessages()
{
MessageBox.Show("Start");
while (ProcessStatus)
{
try
{
MessageQueue myQueue = new MessageQueue(@".\private$\myquelocal");
System.Messaging.Message[] myMessagecount = myQueue.GetAllMessages();
if (myMessagecount.Length <= 0)
return;
myQueue.Formatter = new BinaryMessageFormatter();
System.Messaging.Message myMessage = myQueue.Receive();
byte[] buffer = (byte[])myMessage.Body;
TBCastMessageHeader bcastHeader = new TBCastMessageHeader(); IntPtr bcastHeaderPtr; bcastHeaderPtr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(TBCastMessageHeader)));
Marshal.Copy(buffer, 0, bcastHeaderPtr, buffer.Length);
bcastHeader = (TBCastMessageHeader)(Marshal.PtrToStructure(bcastHeaderPtr, typeof(TBCastMessageHeader)));
}
}
|
|
|
|
 |
|
 |
But, this is an example of why an article is okay, instead of good. The 'code intentionally missing' makes it harder to implement this project. It's why we come here! So we don't *have to* do this, but can use your expertise!
Without a link to the source, this just has too many missing pieces. Newbies can't create a project, debug and step through the code--hence they score it low or ignore it. Those of us that are more experiences but don't have the knowledge of *this specific* tutorial (MSMQ in this case), don't want to spend the couple of hours it always ends up taking creating a project out of 80% code.
Hope to read more, but I hope you add the example project next time.
|
|
|
|
 |
|
 |
Hi
I agree with you that not sharing 100% of the code can be problemmatic for newbies going into this.However pls appreciate the fact that some portions of the code contains client business specific logic and publishing it online is violation of contracts. On the other hand, if you read carefully through the article the missing portions are 1. request assembly 2. SQl assembly.
Number 2 is piece of cake using any Data Access App block. Number 1 is business specific request.
However if you still need some detail help, pls dont be hesitant to ask. Its good to ask and not to complain.
Anupam
|
|
|
|
 |
|
 |
Well if its good to ask...
Please don't post any more articles that are not complete.
|
|
|
|
 |
|
 |
Please don't discourage some one like this. If you don't like it fine. Leave it. Sorry if I hurt your feelings but, think about what I said. If you don't like what I said, leave me also
|
|
|
|
 |
|
 |
Hi,anupamkundu,
could you post your source code of this sample?
Thanks alot,
Michael
|
|
|
|
 |
|
 |
Did you receive the source code example? If so, would you please share it with me as well!
Sincerely,
Kari
|
|
|
|
 |
|
 |
I haven't got anything yet. I wish I could help you.
Regards,
Michael Ma
|
|
|
|
 |
|
 |
Hi,
I have been trying to go through your explanation on asynchronous programming. There was a reference to Assembley1, Assembley2. Can you be more specific about the PrintCheckRequestMessage method.
Thanks
Prashanth Banala
|
|
|
|
 |
|
 |
Hey,
Describe me your problem in details. May be I can help you.
Thanks
Anupam
|
|
|
|
 |
|
 |
Hi Anupam,
We have the same requirement of printing crystal reports to the printer attached to the client machine.
These reports are rendered using a web interface. Some the reports are manual (they are invoked by the user manually) and some of the reports are automatic and attached to a process i.e., they get printed without user intervention.
I have tried implementing the asynchronous programming based on your article. I got confused about the references to requestobject (Assembly1) could you elaborate more on the requestobject and PrintCheckRequestMessage .
Thanks
Prashanth Banala
|
|
|
|
 |
|
 |
Hi Anupam, we have a similar requirement printing the Crystal Reports in PDF formats. Our reports are taking more than 8 hours as its a very huge report more than 120000 pages. could you please send more information or a working copy of the code it might really help us
|
|
|
|
 |
|
 |
Hi,
It is possible to implement MessageQueueTransaction ? (DB and MSMQ in single Transaction)
|
|
|
|
 |
|
 |
Hallo Anupamkundu,
I like this article. But, in most cases asp.net applications have a database somewhere behind, in which case wouldn't it be easier to use a database table instead of the MSMQ? I think the database approach would be easier to handle because there are more tools around to maintain and access database applications than for the MSMQ.
Nigel...
|
|
|
|
 |
|
 |
Very much depends on your infrastructure: what if your web app is in the public arena, but your database sits nice and safe behind a door your not willing to open?
Or in the SOA world where you have no direct contact with components, etc, etc. Using queues means all aspects of your solution are interchangable and inherently scaleable. Upgrading to a different database, say db2? no probs, don't need to touch your web app or DAL on the web side, just place a different endpoint listening to the Q etc.
|
|
|
|
 |