How to get a Channel Queued Messages
During the Iguana Server migration, you might need to manually resubmit queued message from the old Iguana into the new Iguana. There are two ways to achieve it.
Iguana Log Export
Navigate to Iguana Logs
Configure the following Search Criteria:
Channel
Type=Message
Hide Deleted
Time Range (If know the queued message time range)
Choose on Export
Choose A CSV file
Click on Export button to generate CSV
Open CSV in Excel and Delete None “Message“ type logs (such as “Ignored Data Msg“)
Back Iguana Logs with the same Step 2 Search Criteria
Click on “Last Processed Message” link
Scroll up/down to find the “Last Processed Message“ message that has “PROCESSED“ tag and click on it
Click on “Show me a direct link to this entry“ to capture the message refid
Use refid to find the last processed message in CSV file
Find refid in CSV MessageId column and delete all the earlier processed messages include the “Last Processed Message“
The remaining messages in CSV are queued messages
Iguana Translator
Copy the Lua code below into your translator
Update the
CHANNEL_NAME
,QUEUED_COUNT
, andLOG_COUNT
Update Iguana Log API endpoint if you query logs from another Iguana
Run the Lua code
Retrieve Queued Messages from line 56
Lua Code
-- Compare two msgIds and see if id1 > id2
local function compareMsgIds(id1, id2)
local isBigger = false
local id1List = id1:split("-")
local id2List = id2:split("-")
if id1List[1] > id2List[1] then
isBigger = true
elseif id1List[1] == id2List[1] then
if tonumber(id1List[2]) >= tonumber(id2List[2]) then
isBigger = true
end
end
return isBigger
end
-- The main function is the first function called from Iguana.
function main()
-- 1) Define Queued Channel Name and Message Count
local CHANNEL_NAME = 'HL7 to Database 4'
local QUEUED_COUNT = 7
local LOG_COUNT = 20 --Adjust QUERY COUNT if not all queued messages have been queried
-- 2) Query Queued and Ignored Data Msg Messages
local LogResults = net.http.post{
url = 'http://localhost:6543/api_query',
auth = {username = 'admin',password = 'password'},
parameters = {
source= CHANNEL_NAME,
limit = LOG_COUNT,
type="messages",
deleted = 'false',
reverse = true
}, live=true
}
local logXML = xml.parse{data=LogResults}.export
-- 3) Filter and validate only Queued Messages
local filteredLogMsgs = {}
for i= 1, logXML:childCount("message") do
if logXML:child("message", i).type:nodeValue() == "Message" then
table.insert(filteredLogMsgs, logXML:child("message", i))
end
end
-- 4) Get last Processed Message
LogResults = net.http.post{
url = 'http://localhost:6543/log_browse_get_dequeue_position',
auth = {username = 'admin',password = 'password'},
body = "Source="..CHANNEL_NAME,
live=true
}
logXML = json.parse{data=LogResults}
local processedMsg = logXML[CHANNEL_NAME]
local msgId = processedMsg.Date:gsub("/", "").."-"..processedMsg.Position
-- 5) Filter out processed Message
local queuedMsgs = {}
for i=1, #filteredLogMsgs do
if compareMsgIds(msgId, filteredLogMsgs[i].message_id:nodeValue()) then
break
else
table.insert(queuedMsgs,filteredLogMsgs[i].data)
end
end
-- 6) Validate queued messages
trace(queuedMsgs)
if #queuedMsgs ~= QUEUED_COUNT then
error("Not all queued messages have been queried, increase LOG_COUNT")
end
end