|
| 1 | +using System; |
| 2 | +using MongoDB.Driver; |
| 3 | +using NServiceBus; |
| 4 | + |
| 5 | +public class Usage |
| 6 | +{ |
| 7 | + Usage(EndpointConfiguration endpointConfiguration) |
| 8 | + { |
| 9 | + #region MongoDBUsage |
| 10 | + |
| 11 | + endpointConfiguration.UsePersistence<MongoPersistence>(); |
| 12 | + |
| 13 | + #endregion |
| 14 | + } |
| 15 | + |
| 16 | + void MongoClient(EndpointConfiguration endpointConfiguration) |
| 17 | + { |
| 18 | + #region MongoDBClient |
| 19 | + |
| 20 | + var persistence = endpointConfiguration.UsePersistence<MongoPersistence>(); |
| 21 | + persistence.MongoClient(new MongoClient("SharedMongoUrl")); |
| 22 | + |
| 23 | + #endregion |
| 24 | + } |
| 25 | + |
| 26 | + void DatabaseName(EndpointConfiguration endpointConfiguration) |
| 27 | + { |
| 28 | + #region MongoDBDatabaseName |
| 29 | + |
| 30 | + var persistence = endpointConfiguration.UsePersistence<MongoPersistence>(); |
| 31 | + persistence.DatabaseName("DatabaseName"); |
| 32 | + |
| 33 | + #endregion |
| 34 | + } |
| 35 | + |
| 36 | + void UseTransactions(EndpointConfiguration endpointConfiguration) |
| 37 | + { |
| 38 | + #region MongoDBDisableTransactions |
| 39 | + |
| 40 | + var persistence = endpointConfiguration.UsePersistence<MongoPersistence>(); |
| 41 | + persistence.UseTransactions(false); |
| 42 | + |
| 43 | + #endregion |
| 44 | + } |
| 45 | + |
| 46 | + void TimeToKeepOutboxDeduplicationData(EndpointConfiguration endpointConfiguration) |
| 47 | + { |
| 48 | + #region MongoDBOutboxCleanup |
| 49 | + |
| 50 | + var outbox = endpointConfiguration.EnableOutbox(); |
| 51 | + outbox.TimeToKeepOutboxDeduplicationData(TimeSpan.FromDays(30)); |
| 52 | + |
| 53 | + #endregion |
| 54 | + } |
| 55 | + |
| 56 | + void DisableReadFallback(EndpointConfiguration endpointConfiguration) |
| 57 | + { |
| 58 | + #region MongoDBDisableReadFallback |
| 59 | + |
| 60 | + var outbox = endpointConfiguration.EnableOutbox(); |
| 61 | + outbox.DisableReadFallback(); |
| 62 | + |
| 63 | + #endregion |
| 64 | + } |
| 65 | + |
| 66 | + void DisableInstaller(EndpointConfiguration endpointConfiguration) |
| 67 | + { |
| 68 | + #region MongoDBDisableInstaller |
| 69 | + |
| 70 | + var persistence = endpointConfiguration.UsePersistence<MongoPersistence>(); |
| 71 | + persistence.DisableInstaller(); |
| 72 | + |
| 73 | + #endregion |
| 74 | + } |
| 75 | + |
| 76 | + void SBMakoCompatibility(EndpointConfiguration endpointConfiguration) |
| 77 | + { |
| 78 | + #region MongoDBSBMakoCompatibility |
| 79 | + |
| 80 | + var persistence = endpointConfiguration.UsePersistence<MongoPersistence>(); |
| 81 | + var compatibility = persistence.CommunityPersistenceCompatibility(); |
| 82 | + compatibility.CollectionNamingConvention(type => type.Name); |
| 83 | + compatibility.VersionElementName("DocumentVersion"); |
| 84 | + |
| 85 | + #endregion |
| 86 | + } |
| 87 | + |
| 88 | + void TekmavenCompatibility(EndpointConfiguration endpointConfiguration) |
| 89 | + { |
| 90 | + #region MongoDBTekmavenCompatibility |
| 91 | + |
| 92 | + var persistence = endpointConfiguration.UsePersistence<MongoPersistence>(); |
| 93 | + var compatibility = persistence.CommunityPersistenceCompatibility(); |
| 94 | + compatibility.VersionElementName("Version"); |
| 95 | + |
| 96 | + #endregion |
| 97 | + } |
| 98 | +} |
0 commit comments