Prasanna Raman

Ranch Hand
+ Follow
since Sep 05, 2010
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Prasanna Raman

Hello All,

Problem: Getting an error when connecting to 2 different subscriptions with the same name across 2 different topics.

Details

I have a Controller in a Springboot app connecting to an Azure Service Bus using JMSListeners.


Method 1:[/u]



Method 2:


As you can see, the topic names are different, but subscription name is the same. I get an error in the Springboot app as it's starting up.

Here's the error:

   Caused by: javax.jms.JMSRuntimeException: A non-shared durable subscription is already active with name 'XXX'.

I've tried by commenting out 1 of the methods and confirmed it's working, and also tried to connect to a different subscription name and confirmed that that works too. It's just when I have 2 subscriptions with the same name across topics that I get the error above.

I haven't found much documentation around this despite trying quite a bit, and I am really stuck Most of the online tutorials talk about connecting to different subscriptions with different names, so I haven't come across anything similar to my problem. I don't know at this point whether this is in fact possible or it's a limitation of how JMS works?

Thank you so much!
2 years ago
Ron, thank you so much!

I was able to do this:

new ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);

and it's now ignoring UNKNOWN fields.
3 years ago
Here's the stack trace:




Upon some investigation, I think I understand it a little more now. So if I were creating my own model, I could use this -



So, is the question now about how to tell the openAPI config to ignore unknown fields? Is there a way to do this?

This is from the gradle file:

3 years ago
I am not sure I understand exactly how the deserializing task is configured, but I think it's using openAPI (org.openapitools.codegen.languages.SpringCodegen)?

This is the code snippet if that helps:



I am not sure exactly how this all works, but hopefully this is enough information to get some inputs on how to solve the problem.

Please let me know if there's anything else I can provide.
3 years ago
Thank you for your response, Les! Can you elaborate about what's best practice and how this case can be handled?
3 years ago
Hello All,

I just inherited a project where we use openAPI spec, so it currently rejects any extra fields in the payload that's not part of the Swagger spec, so our code throws an exception to the caller when that happens.

We have a problem now because it's an external team that works on Swagger/payload, and they sometimes add fields to the payload without giving us an updated Swagger. It looks like they share this payload with other clients too, so if there's a requirement by another client to have a field added, they add it to the payload, just causing our code to break. If they update the Swagger and the payload at the same time, we won't have a problem, but sometimes Swagger comes later.

The external team that shares the Swagger spec is arguing that it's not best practice to have this strict check, and that we should be able to ignore ANY extra fields in the payload even if it's not in Swagger.

I just want to understand what's best practice here, and if there's a way to blindly ignore ANY extra fields without knowing what might get added in the future.

Thank you very much!
3 years ago
Hello All,

I've set expiration rule through Java code for my S3 objects, but the objects are not expiring from S3.

When I do HEAD-object, I am able to see "Expiration" and the correct rule against the object, but nothing seems to happen even though at least 2 UTC midnights have passed since I set up the rule.

On the other hand, I tried creating a rule manually using the UI in S3. That seems to have removed the object correctly. Both rules had exactly similar prefixes.

When I upload the file, I see that my Java code executes and creates the rule simultaneously, setting up the prefix correctly. I am not sure why removal doesn't happen as expected.

Any help would be greatly appreciated. I can share more details if necessary.

Thank you.
3 years ago
Correct, there is no difference, but I'm just trying to program for any country thay may have different formats! And see how I can make it work.
5 years ago
Ok, and what if the formatting also differs by the type - mobile or landline? USA may be the same, but assuming it's different.
5 years ago

Campbell Ritchie wrote:If you go back to an earlier suggestion that you have a prefix (area code, dialling code, etc.) and number stored as separate fields, can you separate a String into its constituent parts in the constructor?
What about a factory method requiring a non‑null locale as a parameter, returning subclasses of PhoneNumber? Then make all your constructors private.



Can you please elaborate on this? I do have a prefix and a phone number field for my PhoneNumber class, in addition to the PhoneNumberType field. I don't understand the parts about the constructor and the factory method
5 years ago

Campbell Ritchie wrote:There are several ways you can store a formatter object.

  • You can put it into a map as the “V”, but I shall leave it to you to work out what to use as the “K”.
  • You can have subclasses as I suggested here, with formatters being private static fields of each class.
  • If you are using Locales, you might be able to put formatting information into a resource bundle (not sure).
  • You can have it associated with the type enum. But I remain to be convinced that you need a type enum in the first place; do you have an intersection of the range of phone numbers anywhere so there is a landline and a mobile with the same number in the same country? Would you need an additional (?prefix) number to disambiguate them?
  • Ouch! How are you going to describe that in the documentation? Look at that awkward code with two dots in. Why doesn't the toString() method return the phone number correctly formatted? Also a plainToString() method which returns my phone number in the blank formatrather than correctly formatted like this?If you go back to an earlier suggestion that you have a prefix (area code, dialling code, etc.) and number stored as separate fields, can you separate a String into its constituent parts in the constructor?
    What about a factory method requiring a non‑null locale as a parameter, returning subclasses of PhoneNumber? Then make all your constructors private.

    I you are confining yourself to one country only, then a lot of this current post doesn't apply.



    I have the enum not because there is overlap, but because I want the user to be able to select the phone number type when storing, and when viewing. If including the type as part of the phone number is not the ideal way to do this, then please tell me how else this can be done. I probably have bad design here.

    As for storing in map, I do have that map in the PhoneFormatProvider class, and also the inheritance hierarchy for the formatters (based on locale) as suggested by you earlier; but what I don't know is how I can also include the type within the formatter. Should I have USMobileFormatter, USLandlineFormatter etc.?

    Unfortunately, I don't understand what you're trying to say with the toString() methods Can you please elaborate?
    5 years ago
    Now for the getFormatter(Locale locale, PhoneType type) method, how do I implement this if I need to provide formatters based on both locale and type?

    Even in the detault formatter, I will need to do conditional based on landline vs mobile! If a new locale gets added, then I need to get the correct formatter for the locale, and then somehow get the correct formatter for the type for the locale! I am probably confusing myself here, but it keeps getting complicated and I am not sure how to solve this.

    Upon thinking about this further, is this where I could do something like this?



    But even this doesn't solve the problem of how I write the logic to format based on locale and also type Unless I have a formatter for each subtype - as USMobileFormatter, USLandLineFormatter etc..
    5 years ago
    Is this better?

    5 years ago
    I've made some progress, not sure if this is ideal. Please review.







    Is this reasonable? Now, where and how do I implement that Map you were talking about?
    5 years ago
    Thank you, Junilu. I am struggling with how to implement the factory class. How should I proceed from here?



    I know I need to use the 2 parameters passed to getInstance in the factory class somehow, but not sure how I can create the instances.


    5 years ago