Queue 프로그래밍을 할 때 가장 많이 쓰는 Queue 패키지는 보통... MSMQ라고 알고 있다.

그러나 MSMQ는 공짜(!!)이기 때문이기도 하겠지만 어쨌든 성능이 그리 좋다고 할 수 없다. 공짜라서 아쉬운 김에 그냥 쓰는거지... ^^;

그래서 돈이 좀 되는 회사들은 우수한 성능을 자랑하는 IBM MQSeries를 고가로 매입하여 많이 사용한다.

이 IBM MQSeries는 또한 원래 UNIX를 타겟으로 만들어졌기 때문에 NT, UNIX(HP, Sun...)를 모두 지원하므로 이종 플랫폼간의 데이터 전송을 필요로 하는 곳에서 특히 탁월한 성능을 자랑한다.


여기서는 VB를 이용한 IBM MQSeries의 프로그래밍 방법을 간략히 기술한다. 설치나 설정방법 등은 직접 해봐야 알 수 있는 것이므로 생략한다.




[필요한 패키지]


IBM MQSeries ver 5.1 (for NT/2000 : 최신버전이다.)

- 어떤 IBM MQSeries 버전이라도 상관없다. 똑같다. ^^;



[프로그래밍 순서]


1. 프로젝트 - 참조에서 다음의 runtime을 참조한다.

- IBM MQSeries ADSI 5.1 Library (amqmadsi.dll)

- IBM MQSeries Automation Classes for ActiveX (mqax200.dll)

- IBM MQSeries MQAI COM Library (amqzaix.dll)


2. 개체변수 선언

Dim MQSess As MQSession '* session 개체

Dim QMgr As MQQueueManager '* queue manager 개체

Dim MQueue As MQQueue '* queue 개체

Dim PutMsg As MQMessage '* 입력을 위한 메시지 개체

Dim GetMsg As MQMessage '* 출력을 위한 메시지 개체

Dim PutOptions As MQPutMessageOptions '* 입력메시지 옵션

Dim GetOptions As MQGetMessageOptions '* 출력메시지 옵션


3. 초기화 및 생성, 작업

' Queue관련 작업을 하기위한 세션 생성

Set MQSess = New MQSession


' Queue Manger Object취득

Set QMgr = MQSess.AccessQueueManager(QueueManagerName)

If MQSess.CompletionCode <> MQCC_OK Then

MsgBox MQSess.ReasonName

Exit Sub

End If


' 처리할 Queue Object취득

Set MQueue = QMgr.AccessQueue(QueueName, MQOO_OUTPUT Or MQOO_INPUT_AS_Q_DEF)

If MQSess.CompletionCode <> MQCC_OK Then

MsgBox MQSess.ReasonName

Exit Sub

End If


' Queue로부터 메시지를 읽음

Set GetMsg = MQSess.AccessMessage()

Set GetOptions = MQSess.AccessGetMessageOptions()


MQueue.Get GetMsg, GetOptions

If MQSess.CompletionCode = MQCC_OK Then

GetMsgStr = GetMsg.MessageData

ElseIf MQSess.ReasonCode = 2033 Then

MsgBox "현재 큐에 데이타가 없습니다."

Else

MsgBox MQSess.ReasonName

End If


' Queue에 메시지를 씀

Set PutMsg = MQSess.AccessMessage()

Set PutOptions = MQSess.AccessPutMessageOptions()


PutMsg.MessageData = PutMsgStr

MQueue.Put PutMsg, PutOptions


' 종료

Set PutMsg = Nothing

Set PutOptions = Nothing

Set GetMsg = Nothing

Set GetOptions = Nothing

Set MQueue = Nothing

Set QMgr = Nothing

Set MQSess = Nothing



즉, 다시한번 설명하자면, ① 가장 먼저 Queue 세션을 생성해야 하고, ② 세션이 생성되면 그 세션의 관리자 개체를 취득한 다음, ③ 그 관리자 개체에 소속되어 있는 Queue 중 제어할 Queue 개체를 다시 생성하여, ④ 메시지와 옵션을 설정한 다음, ⑤ Queue에 쓰거나 읽으면 된다.


'Tech: > ASP·VB6' 카테고리의 다른 글

VB-메시지박스 자동 종료하기  (0) 2008.06.26
VB 속도향상 팁 45가지  (0) 2008.06.26
MTS와 COM+에서의 Transaction  (0) 2008.06.26
VB-Winsock 소스3 (Gateway)  (0) 2008.06.26
VB-Winsock 소스2 (Client)  (0) 2008.06.26


Posted by 떼르미
,


자바스크립트를 허용해주세요!
Please Enable JavaScript![ Enable JavaScript ]