DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
View Events Video Library
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Integrating PostgreSQL Databases with ANF: Join this workshop to learn how to create a PostgreSQL server using Instaclustr’s managed service

Mobile Database Essentials: Assess data needs, storage requirements, and more when leveraging databases for cloud and edge applications.

Monitoring and Observability for LLMs: Datadog and Google Cloud discuss how to achieve optimal AI model performance.

Automated Testing: The latest on architecture, TDD, and the benefits of AI and low-code tools.

Related

  • Building a DevOps Culture Layer by Layer
  • Unleashing the Power of Hackathons: A Must for Senior and Middle Developers
  • Unlocking Opportunities: The Advantages of Certifications for Software Engineers
  • Adopting Agile Practices for Workforce Management: Benefits, Challenges, and Practices

Trending

  • The API-Centric Revolution: Decoding Data Integration in the Age of Microservices and Cloud Computing
  • Reflections From a DBA
  • How TIBCO Is Evolving Its Platform To Embrace Developers and Simplify Cloud Integration
  • The Winds of Change: How Generative AI is Revolutionizing Cybersecurity
  1. DZone
  2. Culture and Methodologies
  3. Career Development
  4. Batch Module: Obtaining the Job Instance ID in Mule 3.7

Batch Module: Obtaining the Job Instance ID in Mule 3.7

Learn how to grab the job instance ID of any of a Batch job's phases in Mule Batch Module.

Mariano Gonzalez user avatar by
Mariano Gonzalez
·
Aug. 12, 15 · Tutorial
Like (1)
Save
Tweet
Share
2.07K Views

Join the DZone community and get the full member experience.

Join For Free

A popular request among users of the Batch module is the ability to grab the job instance id in any of a Batch job’s phases. Why is that useful? Well, there could be a number of useful scenarios:

  • If the batch communicates with an external system, it’s sometimes useful to pass the local job instance id for reference and management purposes
  • To improve the job’s custom logging
  • Some jobs might want to fire email or SMS notifications for meaningful events, having the job instance id in those messages is obviously helpful.

Example

The id will be exposed throw a flow variable of key ‘batchJobInstanceId’. That flow variable will be available since the very beginning of the input phase. It will also be available on every step and in the on-complete phase. Let’s see an example job:

batch

As you see this job is pretty simple. In all its phases, it invokes a sub-flow which logs the output of #[flowVars[‘batchJobInstanceId’]]. The log output that it produces is the following:

INFO  2015-05-08 18:18:09,599 [[batch].HTTP_Listener_Configuration.worker.01] com.mulesoft.module.batch.engine.DefaultBatchEngine: Starting input phase
INFO  2015-05-08 18:18:09,603 [[batch].HTTP_Listener_Configuration.worker.01] org.mule.api.processor.LoggerMessageProcessor: Job Instance Id is: ba01e1a0-f5c7-11e4-9414-10ddb1daeb6d
INFO  2015-05-08 18:18:09,603 [[batch].HTTP_Listener_Configuration.worker.01] com.mulesoft.module.batch.engine.DefaultBatchEngine: Input phase completed
INFO  2015-05-08 18:18:09,608 [[batch].HTTP_Listener_Configuration.worker.01] com.mulesoft.module.batch.engine.queue.BatchQueueLoader: Starting loading phase for instance 'ba01e1a0-f5c7-11e4-9414-10ddb1daeb6d' of job 'batchBatch'
INFO  2015-05-08 18:18:09,610 [[batch].HTTP_Listener_Configuration.worker.01] com.mulesoft.module.batch.engine.queue.BatchQueueLoader: Finished loading phase for instance ba01e1a0-f5c7-11e4-9414-10ddb1daeb6d of job batchBatch. 1 records were loaded
INFO  2015-05-08 18:18:09,615 [[batch].HTTP_Listener_Configuration.worker.01] com.mulesoft.module.batch.engine.DefaultBatchEngine: Started execution of instance 'ba01e1a0-f5c7-11e4-9414-10ddb1daeb6d' of job 'batchBatch'
INFO  2015-05-08 18:18:09,624 [batch-job-batchBatch-work-manager.01] org.mule.api.processor.LoggerMessageProcessor: Job Instance Id is: ba01e1a0-f5c7-11e4-9414-10ddb1daeb6d
INFO  2015-05-08 18:18:09,643 [batch-job-batchBatch-work-manager.01] com.mulesoft.module.batch.engine.DefaultBatchEngine: Starting execution of onComplete phase for instance ba01e1a0-f5c7-11e4-9414-10ddb1daeb6d of job batchBatch
INFO  2015-05-08 18:18:09,644 [batch-job-batchBatch-work-manager.01] org.mule.api.processor.LoggerMessageProcessor: Job Instance Id is: ba01e1a0-f5c7-11e4-9414-10ddb1daeb6d
INFO  2015-05-08 18:18:09,644 [batch-job-batchBatch-work-manager.01] com.mulesoft.module.batch.engine.DefaultBatchEngine: Finished execution of onComplete phase for instance ba01e1a0-f5c7-11e4-9414-10ddb1daeb6d of job batchBatch
INFO  2015-05-08 18:18:09,644 [batch-job-batchBatch-work-manager.01] com.mulesoft.module.batch.engine.DefaultBatchEngine: Finished execution for instance 'ba01e1a0-f5c7-11e4-9414-10ddb1daeb6d' of job 'batchBatch'. Total Records processed: 1. Successful records: 1. Failed Records: 0

So that’s it. This is a small, easy to use improvement which I hope you’ll find useful. Have any other examples of how the job instance id can be useful? Please share!

career

Published at DZone with permission of Mariano Gonzalez, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • Building a DevOps Culture Layer by Layer
  • Unleashing the Power of Hackathons: A Must for Senior and Middle Developers
  • Unlocking Opportunities: The Advantages of Certifications for Software Engineers
  • Adopting Agile Practices for Workforce Management: Benefits, Challenges, and Practices

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends: