Skip to content
DataMiner DoJo

More results...

Generic selectors
Exact matches only
Search in title
Search in content
Post Type Selectors
Search in posts
Search in pages
Search in posts
Search in pages
Log in
Menu
  • Blog
  • Questions
  • Learning
    • E-learning Courses
    • Empower Replay: Limited Edition
    • Tutorials
    • Open Classroom Training
    • Certification
      • DataMiner Fundamentals
      • DataMiner Configurator
      • DataMiner Automation
      • Scripts & Connectors Developer: HTTP Basics
      • Scripts & Connectors Developer: SNMP Basics
      • Visual Overview – Level 1
      • Verify a certificate
    • Video Library
    • Books We Like
    • >> Go to DataMiner Docs
  • Expert Center
    • Solutions & Use Cases
      • Solutions
      • Use Case Library
    • Markets & Industries
      • Media production
      • Government & defense
      • Content distribution
      • Service providers
      • Partners
      • OSS/BSS
    • DataMiner Insights
      • Security
      • System Architecture
      • DataMiner Releases & Updates
    • Agile
      • Agile Webspace
      • Everything Agile
        • The Agile Manifesto
        • Best Practices
        • Retro Recipes
      • Methodologies
        • The Scrum Framework
        • Kanban
        • Extreme Programming
      • Roles
        • The Product Owner
        • The Agile Coach
        • The Quality & UX Coach (QX)
    • DataMiner DevOps Professional Program
  • Downloads
  • More
    • Feature Suggestions
    • Climb the leaderboard!
    • Swag Shop
    • Contact
      • General Inquiries
      • DataMiner DevOps Support
      • Commercial Requests
    • Global Feedback Survey
  • PARTNERS
    • All Partners
    • Technology Partners
    • Strategic Partner Program
    • Deal Registration
  • >> Go to dataminer.services

dms.SendMessages in loop causes delay?

236 views31st January 2025
1
Apurva Tandon [DevOps Advocate]1.61K 23rd January 2025 2 Comments

Hi I am trying to do _dms.SendMessages in loop to the value of parameters of elements it takes lot of time and goes into timeout, what is the workaround for this?

Scenario:

I am iterating over services in a view, then on each element of that followed by PIDs for which I want value and do _dms.SendMEssages call, but it takes lot of time.
If I try to do in one go, then later it becomes difficult to identify based on primary key.

Can anyone please suggest the best way or approach

José Silva [SLC] [DevOps Catalyst] Answered question 31st January 2025
José Silva [SLC] [DevOps Catalyst] commented 23rd January 2025

Hi Apurva,

I’m not sure I fully understood your question. Could you please provide more details about your scenario and share the code you’re trying to execute? This will help us better understand your issue and assist you more effectively.

Thanks in advance,
Kind regards

Apurva Tandon [DevOps Advocate] commented 23rd January 2025

try
{
foreach (var service in serviceList)
{
var childInfos = service.Children?.ToList();
if (childInfos.Count > 0)
{
var reqParam = new List<DMSMessage>();
foreach (var childInfo in childInfos)
{
var paramsNeeded = childInfo.Parameters
.Where(x => _resources.Any(y => y.ParamterId == x.ParameterID))
.ToList();
foreach (var parameter in paramsNeeded)
{
var msg = new GetParameterMessage(childInfo.DataMinerID, childInfo.ElementID,
parameter.ParameterID, parameter.FilterValue, true);
reqParam.Add(msg);
}
}

try
{
var responseMsg = _dms.SendMessages(reqParam.ToArray());
var response = responseMsg.OfType<GetParameterResponseMessage>().ToList();
paramInfo = response.FindAll(x => !string.IsNullOrEmpty(x.Value.ToString()) && !x.Value.ToString().Equals("EMPTY", StringComparison.CurrentCultureIgnoreCase)).ToList();
}
catch (Exception e)
{
_logger.Error($"Error fetching parameters: {e.Message}");
continue;
}

if (paramInfo.Any())
{
foreach (var childInfo in childInfos)
{
var cells = InitializeTableCells();
CreateElementRow(ref rows, childInfo, cells, paramInfo, service.Name);
}
}
}
}
return new GQIPage(rows.ToArray()) { HasNextPage = false };
}
catch (Exception e)
{
_logger.Error($"Error fetching elements: {e.Message}");
return new GQIPage(rows.ToArray()) { HasNextPage = false };
}

1 Answer

  • Active
  • Voted
  • Newest
  • Oldest
0
José Silva [SLC] [DevOps Catalyst]1.32K Posted 31st January 2025 0 Comments

Hi Apurva,

You might try sending all requests in one go and then processing the responses while mapping them to their respective service names. Here’s a structured approach:

1. Create a list of all DMS messages you want to send.

2. Use a dictionary to map (DataMinerID, ElementID, ParameterID) to the corresponding service name:

var requestMap = new Dictionary<(int DataMinerID, int ElementID, int ParameterID), string>();

 3. Iterate over your service list and populate both the request list and the mapping dictionary:

requestMap[(childInfo.DataMinerID, childInfo.ElementID, parameter.ParameterID)] = service.Name;

4. Send all requests at once and process the responses efficiently. When iterating over the responses, reconstruct the key and retrieve the service name:

var key = (response.DataMinerID, response.ElementID, response.ParameterID);
if (requestMap.TryGetValue(key, out var serviceName))
{
// Process response for this service
}

5. (Optional) If you need to iterate responses per service, you can group them by serviceName for easier processing.

This method should significantly improve performance by reducing the number of individual _dms.SendMessages calls

Just an idea – hope it helps!
Kind regards

José Silva [SLC] [DevOps Catalyst] Answered question 31st January 2025
Please login to be able to comment or post an answer.

My DevOps rank

DevOps Members get more insights on their profile page.

My user earnings

0 Dojo credits

Spend your credits in our swag shop.

0 Reputation points

Boost your reputation, climb the leaderboard.

Promo banner DataMiner DevOps Professiona Program
DataMiner Integration Studio (DIS)
Empower Katas
Privacy Policy • Terms & Conditions • Contact

© 2025 Skyline Communications. All rights reserved.

DOJO Q&A widget

Can't find what you need?

? Explore the Q&A DataMiner Docs