77from pathlib import Path
88from queue import Empty , Queue
99
10- from sqlmodel import Session
10+ from sqlmodel import Session , create_engine
1111from workflows .transport .pika_transport import PikaTransport
1212
1313import murfey .server .api .auth
2525import murfey .server .api .session_info
2626import murfey .server .api .websocket
2727import murfey .server .api .workflow
28- from murfey .server .murfey_db import get_murfey_db_session
28+ from murfey .server .murfey_db import url
2929from murfey .util .config import security_from_file
3030
3131
@@ -162,7 +162,10 @@ def run():
162162 - feedback messages that can be sent back to rabbitmq
163163 """
164164 parser = argparse .ArgumentParser (
165- description = "Purge and reinject failed murfey messages"
165+ description = (
166+ "Purge and reinject failed murfey messages. "
167+ "Provide security configuration and set machine configuration."
168+ )
166169 )
167170 parser .add_argument (
168171 "-c" ,
@@ -177,7 +180,6 @@ def run():
177180
178181 # Read the security config file
179182 security_config = security_from_file (args .config )
180- murfey_db = get_murfey_db_session (security_config )
181183
182184 # Purge the queue and repost/reinject any messages found
183185 dlq_dump_path = Path (args .dir )
@@ -187,7 +189,14 @@ def run():
187189 security_config .feedback_queue ,
188190 security_config .rabbitmq_credentials ,
189191 )
190- handle_failed_posts (exported_messages , murfey_db )
192+
193+ # Set up database and retry api calls
194+ _url = url (security_config )
195+ engine = create_engine (_url )
196+ with Session (engine ) as murfey_db :
197+ handle_failed_posts (exported_messages , murfey_db )
198+
199+ # Reinject all remaining messages to rabbitmq
191200 handle_dlq_messages (exported_messages , security_config .rabbitmq_credentials )
192201
193202 # Clean up any created directories
0 commit comments